]> git.hungrycats.org Git - linux/commit
sunrpc: Fix misplaced barrier in call_decode
authorBaptiste Lepers <baptiste.lepers@gmail.com>
Sat, 1 May 2021 04:10:51 +0000 (14:10 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:29:44 +0000 (10:29 +0200)
commita521954cc34f2df86d2e0fa8a553b25dff6736a4
tree64cc9095d3299ece8ca1d4b6228df546edc3ca08
parent8e27c4731aecfff34c5d33781fb59d7a2a86ef6c
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>
net/sunrpc/clnt.c