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 29761C433F5 for ; Fri, 11 Feb 2022 09:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243287AbiBKJQO (ORCPT ); Fri, 11 Feb 2022 04:16:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348363AbiBKJQL (ORCPT ); Fri, 11 Feb 2022 04:16:11 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14F3E102D for ; Fri, 11 Feb 2022 01:16:11 -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 C26EEB828BB for ; Fri, 11 Feb 2022 09:16:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7439C340E9; Fri, 11 Feb 2022 09:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644570968; bh=/qyRzz6yxbDIoDZ4UGLVdLH2e+3tyq1AN49kQedYeoU=; h=Subject:To:Cc:From:Date:From; b=XZth5NmeYn485vnOTEX0DlBPSlJVobm4wvOZ6YrwW6iweov0ZknCPwcjfhUGknun+ wOAw0QG0C6UJ9u5ponphxbx4gviWA7OdbTz2X6fB2ZFjeoi1Pqdexpv0ItnDqVGzSB XKMStijWI/Q8gEg8mXihc197fwHHpJ48IrHxl70I= Subject: FAILED: patch "[PATCH] NFSD: Fix ia_size underflow" failed to apply to 5.4-stable tree To: chuck.lever@oracle.com Cc: From: Date: Fri, 11 Feb 2022 10:16:05 +0100 Message-ID: <16445709652235@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From e6faac3f58c7c4176b66f63def17a34232a17b0e Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Mon, 31 Jan 2022 13:01:53 -0500 Subject: [PATCH] NFSD: Fix ia_size underflow 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 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 99c2b9dfbb10..0cccceb105e7 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -435,6 +435,10 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, .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;