Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3325744rwa; Tue, 23 Aug 2022 02:53:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR72N5ENpORgrGL72NbziVpanDGFqEbeWku/yvvk0yIncAoD9k8AWaLL5MOqSi59iOLVoNTJ X-Received: by 2002:a05:6402:d05:b0:435:b2a6:94eb with SMTP id eb5-20020a0564020d0500b00435b2a694ebmr2987312edb.87.1661248433182; Tue, 23 Aug 2022 02:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248433; cv=none; d=google.com; s=arc-20160816; b=kJGP1jlktc8TtXPWelDuAC5Gy5wlRM6lfXATif7nhRFYVlfDdGpbIDf5Oo4zsypeH3 vrfLik3Nz2zRiIat+y4PRw+4s45CQK6dQmAsoMUwXmZJ+p/NixzvQDzlURIpt1Gje4bI FOjItMIryreLponMDaj6mWwaka4XcyTTMGNvWr8j3MHhJYzjunfeswXJawUYWhyPiZPN 8kPrq9M6yPCix8EmA3f4leeRCwYHJEtQMh7O3cOgnohqAk2SpmJ8mx1CxxoGE0+aMk6W 2oWtrs+2B7HypAQDxqDcDFp6jJLOttk1bAhrrHOk0k8vqCFmsCZpnZnHVivlXj2VRMit fizw== 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=6OLUrT7ZUPti9hutbmXGMwui+Fg9bHpc54RYM9mpkeQ=; b=Rcy+Yv/mMINi8qE3SnWGTpjt+sjpbzEvbz7t+d7Txwn1P43AZ10gOeX51KWOmIH9OW er+MB6AppMHO/B2Sleix5jVO1PUK1nW7ju2hM4002VjsIbfhQDAC1b3wv7CBrSVC1hkF ideYgbXIyYk+1gNO20JCCwTdwp2klmn0SNqAEtqC+TlNJypuzibEaw66jAE65nOuu3K/ 3mvPt/Ifq3QC3eFfrJEqcm9TgmUdfX7FlQ5sSZCZB9EW9R2zg4GHQvZUUJ2E0lguzqpS 43uSX6moI30AFPUpbAntB1Fll3TNv92nKgnMD5QBBnyqISEw74RcLIhRSMYMFAY2PWg6 Xw2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MDd4EXmU; 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 s27-20020a508d1b000000b0043d127622b2si1722486eds.157.2022.08.23.02.53.27; Tue, 23 Aug 2022 02:53:53 -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=MDd4EXmU; 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 S242866AbiHWIT0 (ORCPT + 99 others); Tue, 23 Aug 2022 04:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242047AbiHWIPC (ORCPT ); Tue, 23 Aug 2022 04:15:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5445725E8F; Tue, 23 Aug 2022 01:10:00 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 48FB46129B; Tue, 23 Aug 2022 08:09:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54794C433C1; Tue, 23 Aug 2022 08:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242198; bh=Ar0Ri1pXQ2u5TEvE1oM8+Sx9bnNlWLzCZzLjllN8NEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDd4EXmU4egIHV3U0GAMvL2CGgo4KJV6jWh9YQNnGBEAhpGjkAiHKi8Ex6V2093kp HTSQDRxFn+DNlr56E1Kcl+Ywi8w7x6QasuR6f4V1YGoxfw6qJJeZ3tbxANodzV6fzj ZVBpYbzSCgc+FwtyNrLjxDjqExBISg4hIfRjbX+E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.19 075/365] SUNRPC: Reinitialise the backchannel request buffers before reuse Date: Tue, 23 Aug 2022 09:59:36 +0200 Message-Id: <20220823080121.306598432@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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 @@ -64,6 +64,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; @@ -292,6 +303,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++; atomic_inc(&xprt->bc_slot_count);