Skip to content

Commit f8f7e0f

Browse files
BLepersTrond Myklebust
authored andcommitted
sunrpc: Fix misplaced barrier in call_decode
Fix a misplaced barrier in call_decode. The struct rpc_rqst is modified as follows by xprt_complete_rqst: req->rq_private_buf.len = copied; /* Ensure all writes are done before we update */ /* req->rq_reply_bytes_recvd */ smp_wmb(); req->rq_reply_bytes_recvd = copied; And currently read as follows by call_decode: smp_rmb(); // misplaced if (!req->rq_reply_bytes_recvd) goto out; req->rq_rcv_buf.len = req->rq_private_buf.len; This patch places the smp_rmb after the if to ensure that rq_reply_bytes_recvd and rq_private_buf.len are read in order. Fixes: 9ba8288 ("SUNRPC: Don't try to parse incomplete RPC messages") Signed-off-by: Baptiste Lepers <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent d9092b4 commit f8f7e0f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

net/sunrpc/clnt.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,12 +2456,6 @@ call_decode(struct rpc_task *task)
24562456
task->tk_flags &= ~RPC_CALL_MAJORSEEN;
24572457
}
24582458

2459-
/*
2460-
* Ensure that we see all writes made by xprt_complete_rqst()
2461-
* before it changed req->rq_reply_bytes_recvd.
2462-
*/
2463-
smp_rmb();
2464-
24652459
/*
24662460
* Did we ever call xprt_complete_rqst()? If not, we should assume
24672461
* the message is incomplete.
@@ -2470,6 +2464,11 @@ call_decode(struct rpc_task *task)
24702464
if (!req->rq_reply_bytes_recvd)
24712465
goto out;
24722466

2467+
/* Ensure that we see all writes made by xprt_complete_rqst()
2468+
* before it changed req->rq_reply_bytes_recvd.
2469+
*/
2470+
smp_rmb();
2471+
24732472
req->rq_rcv_buf.len = req->rq_private_buf.len;
24742473
trace_rpc_xdr_recvfrom(task, &req->rq_rcv_buf);
24752474

0 commit comments

Comments
 (0)