Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp479738pxj; Tue, 18 May 2021 07:39:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtnzLpfBG36u6m+5V8RJMbxsbLgkDbtk9gGN3nKeUNzGBWwSRGk4a4ZPPSI7VQYMeDbf9e X-Received: by 2002:a17:906:cb94:: with SMTP id mf20mr6251964ejb.545.1621348763200; Tue, 18 May 2021 07:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621348763; cv=none; d=google.com; s=arc-20160816; b=m8uzq3WJBrzfyhqMsLfQaBlr6glhpcuwN8uhIylpAjaEpLMmOn+Npa8IhAMFmmk78J gZw7VdiXNmmOmlENpn6LKxW4uMvh5IuO7gyzIK1NuhBc1n9DU+uO39BvohbB+dlnqLR8 4PAmMC3w2dNJj+UvZ13msuM1s7nshRKWjsQAXTGmj5rxAH5ze4fir3UmJAvSSYfW2/jB i5cbpb4etxcEyUo2xGof2GrT/Z6j+7uJl1D7yhb3Sl+ZqS+xGR7MlkoqPUd39zj9xh7K a2oz93jcwC66YRugz1Uz5e212tTU/1upBiLg+DUhfAgLV6QC2J69pyWU96BokqxA2cW2 oLKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qwfKk0ksgsINgecyKJXXNScX9nRh4T7m1fP0XWzkVRw=; b=lOLLJxKfU7DWz1ZMxvT0DYufaIfjcSvNsOmAfRW0QxAh/yDHU5gxzIktd1QtT/7QbQ PLY/OO/KTwLbgV27dfIFgdykFytd3ZbcHONlZrqKGzy3w6uJEqu3D/pk01qHFSBiYvJE qqZwTuB6WTWZJcnofilyVbx9q92VJcli/L0GYWQxnfqYqzsfcOW7+WcCnSJ4rN8sT14n PTmFRTLiUXJRXGi0b17yxjXO9V1padk2Bkr/M8gZGuugM8jsSQhXfPdENE17vaE1J4MG twaLiJMW2diWFbiWWkrHrsQDsUdH3nL+jJ1RL+RmN/XJJzVgEsNAR7muxheBTDXjgyyO F06Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=shhxN+VA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si17566514ede.450.2021.05.18.07.38.57; Tue, 18 May 2021 07:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=shhxN+VA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344980AbhEQPqK (ORCPT + 99 others); Mon, 17 May 2021 11:46:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:55422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245712AbhEQPak (ORCPT ); Mon, 17 May 2021 11:30:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6409E61241; Mon, 17 May 2021 14:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262284; bh=mS6VxbEtVC5o3wNu4nBQgdb3Df2QW62vUCnpfSBqChQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=shhxN+VAQp6wsbSRdNNW6Yo6iaUa6mgLfZRhTYjiYmzcNKChRXqGSZhdXlksbpx7j PuAtREmOS7rwCGmFBWOTKYlZkVv3e3ghckneQSIeu6sirr+BBMiDyXz/vv06HsHLCb OCYEfIpAEoaMc3ssbLdPa6SOKsFMciNw0SKSpQE8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baptiste Lepers , Trond Myklebust , Sasha Levin Subject: [PATCH 5.10 153/289] sunrpc: Fix misplaced barrier in call_decode Date: Mon, 17 May 2021 16:01:18 +0200 Message-Id: <20210517140310.294436841@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baptiste Lepers [ 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 Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- net/sunrpc/clnt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 69d8843a26e0..4a0e8e458a9a 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2459,12 +2459,6 @@ call_decode(struct rpc_task *task) task->tk_flags &= ~RPC_CALL_MAJORSEEN; } - /* - * 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. @@ -2473,6 +2467,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); -- 2.30.2