Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409770rwa; Tue, 23 Aug 2022 04:25:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CvRiQgoocPleZP9GUBbdpstgl1EtERXCB6oRHFOLd2RD8YvhZRGnZ8xq4NDH90Pcumv4u X-Received: by 2002:a62:ea14:0:b0:535:c678:8106 with SMTP id t20-20020a62ea14000000b00535c6788106mr24992442pfh.9.1661253939115; Tue, 23 Aug 2022 04:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253939; cv=none; d=google.com; s=arc-20160816; b=jy9ZRLaXINr10v6ACIHKYTXBHQRCXNZfW6Jk9wObACDV6hwuRm6qv2rOzF2ADcy5p4 smt5xbFl6AFRjso31clBk0SYz3dHvLT7I+rmn9qid8y0TQlu2AggAA/baebDrp4ovoIC rSga1csSYx+0YO6//WS0nyT0ChyPApxAwyAjEmZUCprcAMUiwoe1LX4ncdY9WKOA6tzp 0I/R+Jh/kxm0iQREARB/8E/Ipf3CumQgMKXqSeT09MPMB/TZBTCnCJjZsU1KSSQIMBjZ NiiXQBFi14Ao/2Xk+t7pXNnLIBUMS0h8krOSmUzFkTyLs6//cowWNqYCsK4YG643VRPb u2rQ== 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=M/+IQh7J8q6GYRe81g/eiZwvCMDs4OqiNm0S1vJBTKNEf/6+o1gcprGdvBeDt1wlNC Wfq9XE7EDSGZQkkwXcOFeT9auifnAoFqT1C5spGD7Tc7JBPFKsx7rnF2nyp+YMOYzgm4 4PR+uEGWoWwvsIekOZkdypYT4lprWuNo+25ZidoLvSag6KNRajdrXIO4bNZdDecgrAel d13rSMJ+qbvS9inZu/FOY02dbY0w9BP6kCcbNxyMeUbWZKwVtD+ViNlpY2532fVYTeKo Y3nAPNZiTXsSACO9bqzPlzFwxavG+WMgMCFtXnAy6p84PQcw2L9tZ4At0IlzZjer+cDr Sjdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t3QaiXGA; 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 y68-20020a633247000000b0042ae1ee71e0si2611557pgy.125.2022.08.23.04.25.27; Tue, 23 Aug 2022 04:25:39 -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=t3QaiXGA; 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 S243307AbiHWJt1 (ORCPT + 99 others); Tue, 23 Aug 2022 05:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352571AbiHWJqf (ORCPT ); Tue, 23 Aug 2022 05:46:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EB74DB27; Tue, 23 Aug 2022 01:44:19 -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 3345661540; Tue, 23 Aug 2022 08:43:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29F27C433B5; Tue, 23 Aug 2022 08:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244199; bh=Ar0Ri1pXQ2u5TEvE1oM8+Sx9bnNlWLzCZzLjllN8NEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3QaiXGALtus5VP4P49vqbKBhf+exQtlOg9QIwkTArpm2m5NONVjNGVf7BH76/dOE lp7pPGXpG4Gb+d9y1PPSkM5wttDE3/suWF1p0S2CF78DPIJLTbmGSSbsTH/wfpwbRX 06dCKaybAwLTXnQngyqhOWXCSSoCbStallyVeelk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust Subject: [PATCH 5.15 055/244] SUNRPC: Reinitialise the backchannel request buffers before reuse Date: Tue, 23 Aug 2022 10:23:34 +0200 Message-Id: <20220823080100.903408710@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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);