Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3395570rwa; Tue, 23 Aug 2022 04:11:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ZWXYkWnPldwqtblJ8hj0aHdNkxsjaUp+06Bd5HjFmZBPMMFPDD4Xq5BX5SCovGFbUqvhz X-Received: by 2002:a17:90a:4e46:b0:1fb:45e2:5d86 with SMTP id t6-20020a17090a4e4600b001fb45e25d86mr2890729pjl.193.1661253101277; Tue, 23 Aug 2022 04:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253101; cv=none; d=google.com; s=arc-20160816; b=nFJF5yLJdjW24rpEKWo+GOXOxD+j4yD1P3IhIzFljehGzTBwE+GYDeTat0oZrGlTu9 S/oQgxtdTIOmgtequKPhgMKcCqtm9B2z42u019G/jnt5JhtTX7mFRwlNbShhpiMQUFZc y9S5Bx0uk/v8G31VKq7+OiqiYQ9NoX7g4CzAM/G10Mt/RHL4F3ImRW9qBZQFlorE9A7Q kwVbS3kPD69H9lm5s7bN8/zcgmj1WqSgaGSS7uMzg1P8m0e59sxvhN4I/+dJ8daMYKjS m6f7khei3YoiXe7h0p/2RyjW0Kv7JycIpRVtKENq69C2jEmckXeUwutAfwD91t9zHn0p tN6A== 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=Be0pB2LCeCUI9TNHNh2gEz4ZrJCgBM7QkYh6ZsuF6zs=; b=yo98fqrgE1NUSSYunJ4FlVeFmTnrUzNucsBckx8Naf16mepgFwAQZnrKqcJVK9pc7F g09GIj300XNRo81pidAZnjtPp8lscE2FDMo5yUDpKxIgRffTIdRPMfSnq39cAX1CZtEz iir3xzGy5qdyLtE3vMPD+Btykt9V2q96EvoIiQXrnIYmVQiq4ZybjehDuXBAcvqGpRcn u9Qp8DrWFtb5Htw5PcC7fDVLu9nZqBKLs2v6mFG6CNAnnod4TVpc9isMaHRbfXTmqwCP bBIn4Je65a1Qs0fZbXLRmfj03kB9nbBEqJW9RSH9++PwIgk7Twe5Yhn2gi8IS0bnMdRC plqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ro28e8kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a630245000000b0042a59edc53bsi808009pgc.688.2022.08.23.04.11.30; Tue, 23 Aug 2022 04:11:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ro28e8kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1356410AbiHWKzP (ORCPT + 99 others); Tue, 23 Aug 2022 06:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355947AbiHWKse (ORCPT ); Tue, 23 Aug 2022 06:48:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96EC25E8F; Tue, 23 Aug 2022 02:12:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C7E8B81C66; Tue, 23 Aug 2022 09:12:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0C3EC433D6; Tue, 23 Aug 2022 09:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245929; bh=OQlvZM+K22KXk20z/y80Vu43gP5UH4g2hFg4EP4s7Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ro28e8kxR/SfEbZfBlYwCvrG49ZT/o8oMnVYdAGHgcNFN/hF4QcMcVvpDRaMoJXE+ zavLMQyxWtI/HmxLKNDf3uqoIKz4IkmImbZdITq1keLWe+4BS1oGxiQtPXan/u9TT1 TATvKEQTyaEOWFBXds4sjf2KL6SQAEMGaMKygZMo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 4.19 233/287] SUNRPC: Reinitialise the backchannel request buffers before reuse Date: Tue, 23 Aug 2022 10:26:42 +0200 Message-Id: <20220823080108.889190037@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit 6622e3a73112fc336c1c2c582428fb5ef18e456a upstream. When we're reusing the backchannel requests instead of freeing them, then we should reinitialise any values of the send/receive xdr_bufs so that they reflect the available space. Fixes: 0d2a970d0ae5 ("SUNRPC: Fix a backchannel race") Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/backchannel_rqst.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/net/sunrpc/backchannel_rqst.c +++ b/net/sunrpc/backchannel_rqst.c @@ -69,6 +69,17 @@ static void xprt_free_allocation(struct kfree(req); } +static void xprt_bc_reinit_xdr_buf(struct xdr_buf *buf) +{ + buf->head[0].iov_len = PAGE_SIZE; + buf->tail[0].iov_len = 0; + buf->pages = NULL; + buf->page_len = 0; + buf->flags = 0; + buf->len = 0; + buf->buflen = PAGE_SIZE; +} + static int xprt_alloc_xdr_buf(struct xdr_buf *buf, gfp_t gfp_flags) { struct page *page; @@ -291,6 +302,9 @@ void xprt_free_bc_rqst(struct rpc_rqst * */ spin_lock_bh(&xprt->bc_pa_lock); if (xprt_need_to_requeue(xprt)) { + xprt_bc_reinit_xdr_buf(&req->rq_snd_buf); + xprt_bc_reinit_xdr_buf(&req->rq_rcv_buf); + req->rq_rcv_buf.len = PAGE_SIZE; list_add_tail(&req->rq_bc_pa_list, &xprt->bc_pa_list); xprt->bc_alloc_count++; req = NULL;