Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1979381rwe; Fri, 2 Sep 2022 06:56:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dgZflGn6Cui0jyVGgpWYdDV0V+8l6XE0EllRay2vmGcd0vKk+IBW6V1wBZPueY/r5jPSQ X-Received: by 2002:a63:4b65:0:b0:42a:a707:17a5 with SMTP id k37-20020a634b65000000b0042aa70717a5mr31511018pgl.137.1662126962898; Fri, 02 Sep 2022 06:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662126962; cv=none; d=google.com; s=arc-20160816; b=FNTVgKkmoqHEGVXuDCVdLDdY9mDHrHXv5CdPR10CMfww5B4XNXgT92Wy3YObjip+gd 1ZMmaNvYrgpIvhNbglHuXx1ENxIK2c61TIOvfEu0lG1UP+7y+c45CsPdgWyOEw5Kxd06 A0pZgz9MJcZKOuyzv/9Ic1XOHl933rk8RsCbWVFzG5iM6TFQlNvM7qtNequVwNeA9d5O ZImxLDdeS/Cq0kvWwiFA1fljV81OI6gq7r1S4cBeQbRypLtm8a/PnRoRhLQVkLZd7+Vf 4iMAAJ8LR0sDLdLnGefCyjzvJRPWpLzivE6DaQJjs2Te0PUB9Q7UFx9b/fBDsOHoUaXz X6mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature; bh=wc7Zqm2mMf0ihuP/6hi2mpBCqAn5oKOxTL3x5V5WMws=; b=GEa4fNtSWzmcho8UC36ZzIkRcySKLFPVbvpAe/0XI9iBBXCOHZHaz7qsFXVBZKt2zj yF5QZyc1xZOCPcsRGZPrE2PFhZ4geI5gvWtrPIC1sxgnPMzEs88IloT2symS5Fm1AthY ctj22vIJvQPCWIjbyMhhl7l52XVDStWdOf0de3gUwIJYStZdxPB6dlJbYe0L94Vcq/O5 XVdgWZEwz7FlzsyH8L/aY+rpomlG7WxAhiZwV2NHnS6qa/GTwyEaM+GBBZGvkvTM46A8 PxEWeqWOr/a8KVdAUkmE7gOj3BLS0vAqhPdIyeXrGuhj0KA+/Grd1cWUDjpAPgvxfXxT WEUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vi9xxENC; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a1709026bc700b00174468fdf81si1933920plt.476.2022.09.02.06.55.38; Fri, 02 Sep 2022 06:56:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=Vi9xxENC; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236983AbiIBNco (ORCPT + 99 others); Fri, 2 Sep 2022 09:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236671AbiIBNcA (ORCPT ); Fri, 2 Sep 2022 09:32:00 -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 511F2F1B60 for ; Fri, 2 Sep 2022 06:11:38 -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 CED30B82AA2 for ; Fri, 2 Sep 2022 13:09:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 285D6C433D6; Fri, 2 Sep 2022 13:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662124143; bh=8yJaune/I/GjLWkPAbYvzup7MYyVgo8xj9Dqh8wrCGQ=; h=Subject:From:To:Date:In-Reply-To:References:From; b=Vi9xxENClUxXZQzEckxVa5KtnbzIcfqX+bItUQWraUZn939g5rLKbGjB/tBjwWaNC gBODbUNZCGY5KmAF/Es13jm+OoJ4kPW+kHCOWQxms5Y9Zuv3SN45qRvywnpgFj0X0d ub0bbOMIkC0VQORHS4rs3RjjaEZISURgRnS+UsxnsktPq5dy/PnhYNplrHujRr/wDl 893ftDsNMUmcfnig5ooP3w4YubfAN6Oawt9cJP4VCmHBSFf2S8tgaesSs/GMJgUTcP v1q/AAlX4Dwh8irsd0ElBferEi+Twe+wJmQPopj7u0UPViSffalJ/x8nwTMn0QYacQ V/dRkqPfW8Hpw== Message-ID: <86bb9bc0a5b9e46c93c9918b7df6708ef7e01830.camel@kernel.org> Subject: Re: [PATCH v3 3/6] NFSD: Protect against send buffer overflow in NFSv2 READDIR From: Jeff Layton To: Chuck Lever , linux-nfs@vger.kernel.org Date: Fri, 02 Sep 2022 09:09:01 -0400 In-Reply-To: <166205940565.1435.7170548905174362083.stgit@manet.1015granger.net> References: <166204973526.1435.6068003336048840051.stgit@manet.1015granger.net> <166205940565.1435.7170548905174362083.stgit@manet.1015granger.net> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 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-nfs@vger.kernel.org On Thu, 2022-09-01 at 15:10 -0400, Chuck Lever wrote: > Restore the previous limit on the @count argument to prevent a > buffer overflow attack. >=20 > Fixes: 53b1119a6e50 ("NFSD: Fix READDIR buffer overflow") > Signed-off-by: Chuck Lever > --- > fs/nfsd/nfsproc.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) >=20 > diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c > index 7381972f1677..ddb1902c0a18 100644 > --- a/fs/nfsd/nfsproc.c > +++ b/fs/nfsd/nfsproc.c > @@ -567,12 +567,11 @@ static void nfsd_init_dirlist_pages(struct svc_rqst= *rqstp, > struct xdr_buf *buf =3D &resp->dirlist; > struct xdr_stream *xdr =3D &resp->xdr; > =20 > - count =3D clamp(count, (u32)(XDR_UNIT * 2), svc_max_payload(rqstp)); > - > memset(buf, 0, sizeof(*buf)); > =20 > /* Reserve room for the NULL ptr & eof flag (-2 words) */ > - buf->buflen =3D count - XDR_UNIT * 2; > + buf->buflen =3D clamp(count, (u32)(XDR_UNIT * 2), (u32)PAGE_SIZE); > + buf->buflen -=3D XDR_UNIT * 2; > buf->pages =3D rqstp->rq_next_page; > rqstp->rq_next_page++; > =20 >=20 >=20 Reviewed-by: Jeff Layton