Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp100175iof; Sun, 5 Jun 2022 22:22:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0CsfRs8k7sTFpQJcBRfajBcqKeaXBYXaxb/3VRpC3tDX2LH73ofZOI0v9yELHnPOsVh4Z X-Received: by 2002:a17:902:b418:b0:166:3165:eaff with SMTP id x24-20020a170902b41800b001663165eaffmr22686374plr.96.1654492935171; Sun, 05 Jun 2022 22:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654492935; cv=none; d=google.com; s=arc-20160816; b=rdPfCSWus2g4ZIhJOaoKU/PSaAlJykYLgSqXjFW8lxPjR/WW77QzcsDrRH8M64025r 65+TTSsiFRyOqOkFgOJsDTFHLRdgoDwJ/FKYJ396egX4tG9Zmh+V+/8vZDfVY5GUO4z3 li5hvBbIrenAd2az5GRuM9fbneb00TQQbmYI9QjaDVKJMwvsBLGrnl+47YgHo/3narzw YqFMOABgHUSSF9cinlkfUUHPqEOi43Y80PHQQeCIAbNPxcfTQefSq8oj128TVTm6RGPK AuHAbfgHCCkd//Qyu70wR/A+plyThQnaBuaOPIoOWmWgfSUCct9mF37o3lvXYiTlDqPh kNbw== 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:to:from:subject; bh=baDnc1BnUORxG8/0b/G87AqYVZ5y1kUOzPaKCMedgV0=; b=RV+ATLFlKo7CX2p9yHoug57b5arTZqFK2k3cvZAXXWl3LgbBwMK621H2kDIQUBd6BG Xe4zMCPFNnVkQIUpzx3m2QHEfJz8cYIIxhLFFGrqxT2j0fiowzOIrGqyxmd/JinWPuCj uQBj9WgOWhtS4WnAGppc60A5TkaViB84mYU2Ed1KpKUrMVLNQ3NDXqs7HKd+GchXSXKL 0okW7/SYQI86E/4r2j1rUP7sDk0HHHqg1hxA3QOlkRSfljYYgXTnMs+pFEoiuPAujSeB 4jpizgXq6GxTvq1T8Mu5msm7P38f0tnVtCjHGJrLdus41k/mPLxf7UB1gL8ospf6H/Q3 gJAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s11-20020a63214b000000b003c6dde2ad19si19995204pgm.26.2022.06.05.22.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:22:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 32681195950; Sun, 5 Jun 2022 21:25:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345154AbiFET6c (ORCPT + 99 others); Sun, 5 Jun 2022 15:58:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343714AbiFET6b (ORCPT ); Sun, 5 Jun 2022 15:58:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CFAB4A3D3 for ; Sun, 5 Jun 2022 12:58:29 -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 18518B80DCA for ; Sun, 5 Jun 2022 19:58:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADFA8C34119 for ; Sun, 5 Jun 2022 19:58:26 +0000 (UTC) Subject: [PATCH v1 1/5] SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Sun, 05 Jun 2022 15:58:25 -0400 Message-ID: <165445910560.1664.5852151724543272982.stgit@bazille.1015granger.net> In-Reply-To: <165445865736.1664.4497130284832282034.stgit@bazille.1015granger.net> References: <165445865736.1664.4497130284832282034.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-nfs@vger.kernel.org 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 --- 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;