OSDN Git Service

net/smc: fix application data exception
authorD. Wythe <alibuda@linux.alibaba.com>
Thu, 16 Feb 2023 06:39:05 +0000 (14:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2023 08:09:27 +0000 (08:09 +0000)
commit475f9ff63ee8c296aa46c6e9e9ad9bdd301c6bdf
tree05cf2a50216037be73d8fec572a0aacd520931ed
parente40b801b3603a8f90b46acbacdea3505c27f01c0
net/smc: fix application data exception

There is a certain probability that following
exceptions will occur in the wrk benchmark test:

Running 10s test @ http://11.213.45.6:80
  8 threads and 64 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     3.72ms   13.94ms 245.33ms   94.17%
    Req/Sec     1.96k   713.67     5.41k    75.16%
  155262 requests in 10.10s, 23.10MB read
Non-2xx or 3xx responses: 3

We will find that the error is HTTP 400 error, which is a serious
exception in our test, which means the application data was
corrupted.

Consider the following scenarios:

CPU0                            CPU1

buf_desc->used = 0;
                                cmpxchg(buf_desc->used, 0, 1)
                                deal_with(buf_desc)

memset(buf_desc->cpu_addr,0);

This will cause the data received by a victim connection to be cleared,
thus triggering an HTTP 400 error in the server.

This patch exchange the order between clear used and memset, add
barrier to ensure memory consistency.

Fixes: 1c5526968e27 ("net/smc: Clear memory when release and reuse buffer")
Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_core.c