Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2995989imm; Sun, 1 Jul 2018 09:58:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfQzzjVIxFsVhYD+tHTGfR6aXJaAqa+nymTVvg17Oii7SF4+Q3uy7fDwrQGWVFFynXNZJNu X-Received: by 2002:a65:4a49:: with SMTP id a9-v6mr17309639pgu.267.1530464309602; Sun, 01 Jul 2018 09:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464309; cv=none; d=google.com; s=arc-20160816; b=vBrQTSlk+EPj4SC+DqHX++sbJEsWs1AcINQM+dLZFv/k2EjUcdwBe2kq+O6J08aBUq qmPgZ+ZOxKTOM7kvuPII/+z20tBJyAYOux/n3lEynPei2jIXYGphnz3UgqxzPSwKWIFE rl6w17Zu3d7lBBO5kT9DonzwSNfS+9+ZKXL5BN08L02/yms0a3roqJ7jOdz61ud6IuMf wRsxaMDgZ8qEUfBuTn/l6eXhBGQiBd6ecJoDpbZrMKDfmOPo1N0S9DV6aFHW0IEbUi4b Svfdgxlxm4GkjIvgli6BHjfIoDnodpvKTPXKqBefcNrxU8D8oH/Kcoil+h8r5XdUc6Qk mnQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Iby+5Yja1AfZE7uJDpsA4Gr5YlPhYP5t3S/4UYil9B8=; b=COSksSyPUdLqklaKawSfrwgN2E6h90q0Pl/AvJ0VKtnc92d2e6aXZLVxUzumfNgqCw qrkaGBFcXChaE0SA9UyETiHfAeWRCBKMs87fjYj1uB39qn1HjVOGvbVWegGCrZZQ3y4T HoXK7Tv8UzjPm3L6HJ47eINufiC1gtJPTRVFF/fU3SQ7dQS+Tl8PpsDfxsoAiYvUX5+2 cio0Hd36vO/ZGKSXc65UT64Wwif5xLC2xb/lsurxTy/OC4rWEAmvKqtrhhYTcN/2MTfe Y+cWxk/GFnnSF423JK16NrVlLrLY4Yr/XMcJ68i4HtM/ayYMZIWk4EYTAjACbWixaECE dbCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6-v6si9677971plr.437.2018.07.01.09.58.15; Sun, 01 Jul 2018 09:58:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753562AbeGAQ4W (ORCPT + 99 others); Sun, 1 Jul 2018 12:56:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38126 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753669AbeGAQow (ORCPT ); Sun, 1 Jul 2018 12:44:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9182892B; Sun, 1 Jul 2018 16:44:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Mayhew , "J. Bruce Fields" Subject: [PATCH 4.17 180/220] nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir Date: Sun, 1 Jul 2018 18:23:24 +0200 Message-Id: <20180701160915.736807134@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Scott Mayhew commit 9c2ece6ef67e9d376f32823086169b489c422ed0 upstream. nfsd4_readdir_rsize restricts rd_maxcount to svc_max_payload when estimating the size of the readdir reply, but nfsd_encode_readdir restricts it to INT_MAX when encoding the reply. This can result in log messages like "kernel: RPC request reserved 32896 but used 1049444". Restrict rd_dircount similarly (no reason it should be larger than svc_max_payload). Signed-off-by: Scott Mayhew Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4xdr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3651,7 +3651,8 @@ nfsd4_encode_readdir(struct nfsd4_compou nfserr = nfserr_resource; goto err_no_verf; } - maxcount = min_t(u32, readdir->rd_maxcount, INT_MAX); + maxcount = svc_max_payload(resp->rqstp); + maxcount = min_t(u32, readdir->rd_maxcount, maxcount); /* * Note the rfc defines rd_maxcount as the size of the * READDIR4resok structure, which includes the verifier above @@ -3665,7 +3666,7 @@ nfsd4_encode_readdir(struct nfsd4_compou /* RFC 3530 14.2.24 allows us to ignore dircount when it's 0: */ if (!readdir->rd_dircount) - readdir->rd_dircount = INT_MAX; + readdir->rd_dircount = svc_max_payload(resp->rqstp); readdir->xdr = xdr; readdir->rd_maxcount = maxcount;