From: Baptiste Lepers Date: Sat, 1 May 2021 04:10:51 +0000 (+1000) Subject: sunrpc: Fix misplaced barrier in call_decode X-Git-Tag: accepted/tizen/unified/20230118.172025~7262^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8f7e0fb22b2e75be55f2f0c13e229e75b0eac07;p=platform%2Fkernel%2Flinux-rpi.git 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: 9ba828861c56a ("SUNRPC: Don't try to parse incomplete RPC messages") Signed-off-by: Baptiste Lepers Signed-off-by: Trond Myklebust --- diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index c2a0112..f555d33 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2457,12 +2457,6 @@ call_decode(struct rpc_task *task) } /* - * Ensure that we see all writes made by xprt_complete_rqst() - * before it changed req->rq_reply_bytes_recvd. - */ - smp_rmb(); - - /* * Did we ever call xprt_complete_rqst()? If not, we should assume * the message is incomplete. */ @@ -2470,6 +2464,11 @@ call_decode(struct rpc_task *task) if (!req->rq_reply_bytes_recvd) goto out; + /* Ensure that we see all writes made by xprt_complete_rqst() + * before it changed req->rq_reply_bytes_recvd. + */ + smp_rmb(); + req->rq_rcv_buf.len = req->rq_private_buf.len; trace_rpc_xdr_recvfrom(task, &req->rq_rcv_buf);