Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3067740pxj; Mon, 17 May 2021 16:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAZ7pUr5kl3wA01qtz1myXjKWxI0SWOHbb58BxziCcwC3tJnPFYNXWOOHD4CqkSd2R9af+ X-Received: by 2002:aa7:da99:: with SMTP id q25mr3339218eds.198.1621295861920; Mon, 17 May 2021 16:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621295861; cv=none; d=google.com; s=arc-20160816; b=xP1sJ7pIFJQ8FArNRd0SFjRO4Qw76NdihSmgAsc34HnW3XNQPg1Z+UMvVK2B/hyc/g PqQsY5Nmjx3i+D8JhCk44Pd5ErOwut2J28t9wHakZ+YcZe3R5Yv0yU/zwZgduPeSD9WD MPZLqbsXtKgL/TCVbpjOlKWdTwfgWzCeZVSTD3EpefgFTcYfGRspOqJB5bm42vryP7/1 A5gg13oOM1yDYEyWunIxqKi1wnQD5mIheYYqOH3INbIvqEXUdNsfJmC4x6Q1TujyNTqw FSaEcJ+5BPCuvlBBdfRsoczCS+lHh14NledvBc1wWHPKBUTA5uJ1rx3saZXfmQzE+nt0 TABw== 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=tUjrBl7/R4D/4yy6RE0kdmFNUrtkve2cOFHs+MYRp4I=; b=eDtQLvCKiVoIUCMKYXWisvl1tVI7v1OlTkigbd2k8zklBuiJiuzqBBVU/0PJ+CiZpV O6dvJu01CG/xpCeLN6O5obAqovcfA3rUU8KrY16mrOtjsu/x5w/PNFS06bV9U3oYfdJK 4nthSZYoK0NIcQYnrh+AQytHqzJ4FlxfdNJCgvscSv0AJxyIMyrZ2gcCxGKiTSSyVs4f fBfLiIu+RYG2Os16yfMIDG+z8K9ErIXgqxp/XzoAdzYhrmICIVVgrsdGpzmyxfdg9CpN EFeUMvgh7YDc8RZjOqY6v/L+EAHrulOhbE8Lfm1A964EUFXjBdtgULux9ewsgVzi1K7m FQmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="UwZm/wS9"; 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 bg23si10387303ejb.668.2021.05.17.16.57.12; Mon, 17 May 2021 16:57:41 -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="UwZm/wS9"; 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 S239718AbhEQOYo (ORCPT + 99 others); Mon, 17 May 2021 10:24:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:33294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238539AbhEQOV3 (ORCPT ); Mon, 17 May 2021 10:21:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7394B610A8; Mon, 17 May 2021 14:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260701; bh=InIh6HKvECFj20U6L9vgh3JjpNCfwKZj7DEXA3TKNOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwZm/wS9sJ1iYAwZ1grARQ6IS+2RfFND2ybN0wnu208VqP/ZdYQyi+UtUBu7MKTTV ONiFjxtRvD9V8ImIUoAttYwBlfnlrNryvQzYK6ZWKbZQpnDXufVTAyO7f04GjyJq3X PanUuIcCRo6/sW8dEeHwzJtGh8Eo9g3+YmMV/2OE= 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.12 201/363] sunrpc: Fix misplaced barrier in call_decode Date: Mon, 17 May 2021 16:01:07 +0200 Message-Id: <20210517140309.379019819@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 c2a01125be1a..f555d335e910 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2456,12 +2456,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. @@ -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); -- 2.30.2