From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1059C433F5 for ; Mon, 14 Feb 2022 10:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346500AbiBNKTE (ORCPT ); Mon, 14 Feb 2022 05:19:04 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347491AbiBNKQd (ORCPT ); Mon, 14 Feb 2022 05:16:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7C07C146; Mon, 14 Feb 2022 01:54:04 -0800 (PST) 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 CEB6DB80D6D; Mon, 14 Feb 2022 09:54:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F37BEC340E9; Mon, 14 Feb 2022 09:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644832442; bh=90L42e49gTnIttG60Vd1WAt35ktpCOrBMIYNDCAlMsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FqnNQHDtl22qGgGxY9DDRAwkpYQDRpeBYoM9bFWSIwSrGiiTj1e21cywTarAwvb0m 2jaT1j1yMp7kIO8JCENZKrvF2DOOmYO87/jMgQxXzJcpBZMAzicXCDKva50cLgwHvT 1yVyeUQRsslgvhzm0k5wnnvhGSnSklGmBAowACpg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever Subject: [PATCH 5.16 016/203] NFSD: Fix ia_size underflow Date: Mon, 14 Feb 2022 10:24:20 +0100 Message-Id: <20220214092510.772279592@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092510.221474733@linuxfoundation.org> References: <20220214092510.221474733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuck Lever commit e6faac3f58c7c4176b66f63def17a34232a17b0e upstream. iattr::ia_size is a loff_t, which is a signed 64-bit type. NFSv3 and NFSv4 both define file size as an unsigned 64-bit type. Thus there is a range of valid file size values an NFS client can send that is already larger than Linux can handle. Currently decode_fattr4() dumps a full u64 value into ia_size. If that value happens to be larger than S64_MAX, then ia_size underflows. I'm about to fix up the NFSv3 behavior as well, so let's catch the underflow in the common code path: nfsd_setattr(). Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -434,6 +434,10 @@ nfsd_setattr(struct svc_rqst *rqstp, str .ia_size = iap->ia_size, }; + host_err = -EFBIG; + if (iap->ia_size < 0) + goto out_unlock; + host_err = notify_change(&init_user_ns, dentry, &size_attr, NULL); if (host_err) goto out_unlock;