Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3051614imm; Sun, 1 Jul 2018 11:06:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpda5O+3TzQa5sWNNnvXmT9P75UbJfFtqeaordjlrlWIxD4SKgnGy7NhYBa+W0s78ZKisj9t X-Received: by 2002:a62:e903:: with SMTP id j3-v6mr22551783pfh.228.1530468401398; Sun, 01 Jul 2018 11:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530468401; cv=none; d=google.com; s=arc-20160816; b=jiiohus6ute1HNgiJrI7fPfDsNDbKpCPEcOmCZyuq2cUJybuIPJdwnGEJZhcs42JaN u+1NnwxaIV4tHxn5I9nm/AoG3F13L+Imer1H+yGSBFAjB65IEgJPbdiJVvMcU5ZJeHon hhVZ2JqyelCD/6crSvf51Z5a1esSQeDVLhRhIdTsnVd2O1NAa5gPpclXkcVd4pOvvwRk PD1HEuiZMF32KHYvpIKaJqyieH4UD1H91BpmP9mxUHrEowJhbQ4hTWcEIwS8GUwBlfFI eiqMqWIvOIwHp+1bKym1wv4fa3it1m4iQkIkqDsqR+qEkRjEGP3YbaA0IWNMpSLRZJum KPnQ== 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=cL0P6mohWRNVAg0Hnj292s5VbuGwe5RJUk9a5yvV7VM=; b=DWy2J0S8/OTEXOutdDG0tAd37oB3gOxBaFYpnXP2K1IYq40b8tJdHeP31mUNqCfbMd 2jtpWp/Ty74Vq5PC0rUmuSgIH9n8jG+PBPocjLZJ2Y3el0x1iZDdgzFqFH3jVtDTFZk3 qMNmT8IwWPm3OhI0wmI6obWM+JB4njuhAdYzstLeFhlI0E45oLes6aDfJL/F76JDofW/ 2bQLCIy5/7qOkr9laQzxYfpGHSsbyzuHXwTj/+IrdbU+HqlNDBUkT2X6JXCQGM91JOVI Caq4eNnMasEGBKokgIsfJN4irMZfQ/m22yEqZR+X6ibICoGFwdUIljkwugNqCvx2TWf8 W6NA== 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 s184-v6si12618544pgb.161.2018.07.01.11.06.27; Sun, 01 Jul 2018 11:06:41 -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 S1030329AbeGASFc (ORCPT + 99 others); Sun, 1 Jul 2018 14:05:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34452 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965818AbeGAQ3M (ORCPT ); Sun, 1 Jul 2018 12:29:12 -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 66EF792B; Sun, 1 Jul 2018 16:29:10 +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.9 084/101] nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir Date: Sun, 1 Jul 2018 18:22:10 +0200 Message-Id: <20180701160800.521759316@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -3638,7 +3638,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 @@ -3652,7 +3653,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;