Skip to content

Commit 60bb2ce

Browse files
BLepersgregkh
authored andcommitted
sunrpc: Fix misplaced barrier in call_decode
[ Upstream commit f8f7e0f ] 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 <baptiste.lepers@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 208af7f commit 60bb2ce

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎net/sunrpc/clnt.c‎

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

2462-
/*
2463-
* Ensure that we see all writes made by xprt_complete_rqst()
2464-
* before it changed req->rq_reply_bytes_recvd.
2465-
*/
2466-
smp_rmb();
2467-
24682462
/*
24692463
* Did we ever call xprt_complete_rqst()? If not, we should assume
24702464
* the message is incomplete.
@@ -2473,6 +2467,11 @@ call_decode(struct rpc_task *task)
24732467
if (!req->rq_reply_bytes_recvd)
24742468
goto out;
24752469

2470+
/* Ensure that we see all writes made by xprt_complete_rqst()
2471+
* before it changed req->rq_reply_bytes_recvd.
2472+
*/
2473+
smp_rmb();
2474+
24762475
req->rq_rcv_buf.len = req->rq_private_buf.len;
24772476
trace_rpc_xdr_recvfrom(task, &req->rq_rcv_buf);
24782477

0 commit comments

Comments
 (0)