Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp621131iog; Mon, 13 Jun 2022 09:18:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZa74kFnBmo7vGRlb4Dhtu3q6CLFB+1fNwuGShqkgX1tnEjbFe3feWJRFvsTGcdzfCLu0p X-Received: by 2002:a63:788:0:b0:3fc:6922:704 with SMTP id 130-20020a630788000000b003fc69220704mr359276pgh.6.1655137086000; Mon, 13 Jun 2022 09:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137085; cv=none; d=google.com; s=arc-20160816; b=D39yFHOdKICNmvY/Ma6454+9LYnU98Pe51rfbpGxqjEtQrUXRPpciNWa9oAkEk8eX2 PEpapyixlLHY5iQdionpD5xWPq7QE9Joek3GukiH9OCIhWD0u57INHhpuKUVRkJdYtg6 44uqmQV1vVTsSe9wdVpF+OjqwLICTeLZNu2Pr5mDhIh6OqoR59W2xRsyPA3hamrucziy 3o7N8ZzSF7V/Zx9tSAP8koOlrmaefgMiTpMB5rowvbnDfSH0IK0fm4bk5LsyGHMtj4BP DgXt3tHRmVjr/fcXVcfkLLyf2PBTbaFbXP0CkeWCoEGRmsaZ7Pn2kwQ0f54a83iLzEtY HgQQ== 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=+Uph49ySckKahDZ2qJ28Gf43qId+Rruo4QQTWt5YK0k=; b=xWmWN79C3XzDIm8C/HYJQzBK+WD9hDLCAVeXyqf0isZSuLOBxjJtb2IG1Yevg4SxmT Q2/MRMLIGGV4tNAKa6zs14P8qfAhcFb3HRw5GGgHKiowQCz8ddMLxTwgFOXGXfRn3sFf SHUseDhv3Edp8u3nN8TjNzQEcvV6lqkbSqG5hGeTGp+xSK9YJH+euv5GKJ1lqYhObIXx 1FgVUVGi70wkUopPbbvxSVWg6HfUSQoNOx+gnmDAxRmAtLBAYV7GU1euFjSk9GlEHx5a KJltfClc2lFAVGlGUxmigJhSCVBHE72cmsExqxihV2BrXEn8kKV9aNblojX+iHBCZAgU AhtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UE16g4n9; 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 c1-20020a056a00248100b0050d429bb67esi400161pfv.82.2022.06.13.09.17.53; Mon, 13 Jun 2022 09:18:05 -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=UE16g4n9; 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 S1355986AbiFMLnb (ORCPT + 99 others); Mon, 13 Jun 2022 07:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355501AbiFMLjC (ORCPT ); Mon, 13 Jun 2022 07:39:02 -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 1E96A2C115; Mon, 13 Jun 2022 03:48:48 -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 BF2C5B80D3C; Mon, 13 Jun 2022 10:48:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 359A5C34114; Mon, 13 Jun 2022 10:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117325; bh=m4GkGD1TQZ82b2X5Dt0e7N+1LKfnd4Of2X9Q6bHmC+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UE16g4n9JYkIkVVGS1wg3pm42B97UMxLka1x/NYAda0DipgCp0UEu68qgUKep9rzx vB+haFx2cDPHyCwnOQMut5cqsE/BktWaEDVD4ha9hvxjqmRoOlo4n4PrqWDYYlUnE6 3QC02zAm6mZe0UXiLZZx4m26oJfbBAOnyjzT8tRY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , NeilBrown , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 5.4 356/411] SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer() Date: Mon, 13 Jun 2022 12:10:29 +0200 Message-Id: <20220613094939.372660806@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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: Chuck Lever [ Upstream commit 6c254bf3b637dd4ef4f78eb78c7447419c0161d7 ] I found that NFSD's new NFSv3 READDIRPLUS XDR encoder was screwing up right at the end of the page array. xdr_get_next_encode_buffer() does not compute the value of xdr->end correctly: * The check to see if we're on the final available page in xdr->buf needs to account for the space consumed by @nbytes. * The new xdr->end value needs to account for the portion of @nbytes that is to be encoded into the previous buffer. Fixes: 2825a7f90753 ("nfsd4: allow encoding across page boundaries") Signed-off-by: Chuck Lever Reviewed-by: NeilBrown Reviewed-by: J. Bruce Fields Signed-off-by: Sasha Levin --- net/sunrpc/xdr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 7ef37054071f..cb8740d15633 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -608,7 +608,11 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, */ xdr->p = (void *)p + frag2bytes; space_left = xdr->buf->buflen - xdr->buf->len; - xdr->end = (void *)p + min_t(int, space_left, PAGE_SIZE); + if (space_left - nbytes >= PAGE_SIZE) + xdr->end = (void *)p + PAGE_SIZE; + else + xdr->end = (void *)p + space_left - frag1bytes; + xdr->buf->page_len += frag2bytes; xdr->buf->len += nbytes; return p; -- 2.35.1