Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp662033iog; Mon, 13 Jun 2022 10:06:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ub72NW0barBUXHVVBLreCTQ6dzdZqI/Fa3x4XHBMaNHa/FtXe0zFi+elsI3xlqLX4fWZUu X-Received: by 2002:a17:903:3254:b0:168:dadc:6c81 with SMTP id ji20-20020a170903325400b00168dadc6c81mr584928plb.13.1655139971609; Mon, 13 Jun 2022 10:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655139971; cv=none; d=google.com; s=arc-20160816; b=yqG6dZFg5MoZBbB/3DOV+ulq+q0zRkp8p6I3A2VUvb9PnOrCJKFGwVliN5tMRsiAnd TQHsdPxLGHnnqrSGjE4NxVNwyIPV/T+xMiYybYAa03i0Gwd/8nvKmgdYuoYOLFovbH4A Mylv3AkF3rIp/kmGpBty3eiAr9NVpoOaxr5OE58+4aWDdNa9q53uRDHI+w+is0/D376I 8QW8aQf/rfotQAr9+oU8uaCPJr+Gqi7neQdeT7faEYHTgsqVmwpwfxs7Lm3yXf8JSiV/ DiP7fn74h7P65iVjjozaiT17T9jOHPdKwRAzn92nRM8XIrkoaMS9PoIQ/7+3CG/JRejx 2gMQ== 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=JmgVLLYOtO+uggDdwgAH8gDBPomJTnMpJK7ZRtu3ahk=; b=Lyo2/Mq6tmAK4TCD4SWYYQBVPu0pDn9y4zWZkU/i84BCf7/igOQsPlM8h0Aoo5gB3G WrAQiyA0XP5BSADsY+MD0qx1SRB5y/amPfMYmiJpmwI51zgt+ExqLfRjxg9ueql0COTu pkxH66oqAo+XW69EicpgF1rvDbQeWNy37XBtSIqcQn1HcdimsQ43peoUolhM5puEeC9V 4jKJSj0270ydNM6S8DZS+H+NepnbMfuzhoPc6UgC7MVrRPvP9kptEYkh+v0Q6ecZb8wo HEpG1a3CsCUGLu+mooDtPQlQxbwiYi23ebqMJwL4zsnlDeEqhqQJsMCw22H322Bn9Grm d/5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kyrNTr8j; 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 128-20020a621786000000b0050dec7ee78dsi9050790pfx.43.2022.06.13.10.05.57; Mon, 13 Jun 2022 10:06:11 -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=kyrNTr8j; 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 S1380013AbiFMNwa (ORCPT + 99 others); Mon, 13 Jun 2022 09:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379189AbiFMNrT (ORCPT ); Mon, 13 Jun 2022 09:47:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98AB91FCF6; Mon, 13 Jun 2022 04:32:56 -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 7D939B80D3A; Mon, 13 Jun 2022 11:32:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C027AC3411E; Mon, 13 Jun 2022 11:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119973; bh=voYXGHQ0EmEGqrT//5SsbK1zE1x2gYhf/na/v6VV+DU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyrNTr8jC/ltR9QvS36TYuusW92Owa7Bk5yXv1hWv4P4z88BlfOhPcH5UMQbhYauF zdMbFfJeVRMpdSh0fDwi+YPqJ5VK3cxz+5dZwOpPYjTrA8ZlWwB/I8r5RIrUTsJYMr DeZUojAOrXggBbUoDAN+tjY1uOL9uKWeFTesnEpA= 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.18 205/339] SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer() Date: Mon, 13 Jun 2022 12:10:30 +0200 Message-Id: <20220613094932.882613530@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@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 df194cc07035..b57cf9df4de8 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -979,7 +979,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