diff options
author | Baptiste Lepers <baptiste.lepers@gmail.com> | 2021-05-01 14:10:51 +1000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-05-19 10:08:27 +0200 |
commit | a04c2a398dc9069297b416477ada3f8a3d675741 (patch) | |
tree | 575e74c96ff722a2f744522e2fea305860b5068e /net/sunrpc | |
parent | b8168792c3fb42136134f6cfee880f4ef2469221 (diff) | |
download | linux-stable-a04c2a398dc9069297b416477ada3f8a3d675741.tar.gz linux-stable-a04c2a398dc9069297b416477ada3f8a3d675741.tar.bz2 linux-stable-a04c2a398dc9069297b416477ada3f8a3d675741.zip |
sunrpc: Fix misplaced barrier in call_decode
[ Upstream commit f8f7e0fb22b2e75be55f2f0c13e229e75b0eac07 ]
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 <baptiste.lepers@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/clnt.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index f1088ca39d44..b6039642df67 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2506,12 +2506,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. */ @@ -2519,6 +2513,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; /* Check that the softirq receive buffer is valid */ |