Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3313066imu; Sun, 11 Nov 2018 12:09:24 -0800 (PST) X-Google-Smtp-Source: AJdET5c5fN23ZdGFs+L8oYakJsGGPt01QcL8pdIjDM0/iWKIrsF9MYMdxBTBa6UUs1Y/KTlkgsCL X-Received: by 2002:a63:585c:: with SMTP id i28mr15127272pgm.178.1541966964509; Sun, 11 Nov 2018 12:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966964; cv=none; d=google.com; s=arc-20160816; b=ZTl23y96Q5IyipE5GTVk4Mq4uXN4O/lLD+OqyRuhvZJiBuLQLFKCpQ2dLLAAQ7w8pD dQH8wBmMwgDjQXkPmThoeTMdUEIF++jqQH5tZMAyH5/SOvWA0cbio7e7hkwpcsyDEA/J k4C9N/lfoDa0eBieqCsJxpSgrJc4uEEOcHGmyXVcCpYplfelwcupxLDvoij9Jwlg6Hqf t6d0HTDQ19sffdIYCQ7LyQ84G7dW3f1x6bKA2BKxuaZwcnb5u5XEguDLRhnxxev3Y0op ug7E4nICc0m4lPpZ9cSLC41MgBX40m67XPMPcthOg1X9eFip/9pNzmRbX7NItUDsxk/j gAhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Odoax2ueU15pssMe2ln60HTS/xnkUoPKaThvrTpVSDo=; b=wrwU42LSeH3w4F4EOa9D+q1UA/waKifkDk6cwfllBJu+2Je1rG1ibeT+VnRLrRRpxa IOkfXds7L0TNALhbhn7d60rKwn1YkDPHlUOjoTN6sCvPAz14c0opc+Toxb7zS1gPvhuZ LIkaTUGfdZApORvF6vokWWF/b56KGanMEyEp8NcGVHL1S/47uI2VGEiCkjcIQ9ZfsA0B fe6Q/GtaAJjAV3vssIJFSGrNj3vAtartlslOgVxsnZdpAfOQTNdj10GTlXl2CWhEyvnc 0XDyMzUHdkqGIMS37fMc1a4XGqMDp2sDGQ6rwyUN0vxlsG2cB8B5BgSpl3SehELQ9Gpj /JjQ== 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 go17si15252603plb.266.2018.11.11.12.09.08; Sun, 11 Nov 2018 12:09:24 -0800 (PST) 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 S1731503AbeKLF5F (ORCPT + 99 others); Mon, 12 Nov 2018 00:57:05 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52156 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730988AbeKLF5E (ORCPT ); Mon, 12 Nov 2018 00:57:04 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtD-0000lJ-Kr; Sun, 11 Nov 2018 19:59:23 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001Oq-DZ; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Scott Mayhew" , "J. Bruce Fields" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 035/366] nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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 Signed-off-by: J. Bruce Fields Signed-off-by: Ben Hutchings --- fs/nfsd/nfs4xdr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3343,7 +3343,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 @@ -3357,7 +3358,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;