Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FEE215175 for ; Wed, 26 Feb 2025 02:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535997; cv=none; b=QANjp5JIZE+EtBd1K6BkVLYRmZlKFvZGf5w07iHvKvdNi8GfL24bfCtGCMG12XClA5Pd/BoqzwR5FCG9Tyv7oJnUq33Bun7X26qtA/Bt7iLcSGj8+zYqGMOQqUFuhyTDMkSGzJAV9ZAKX4sy21oMTk+fCAFOdOrG73IkpCrL+rI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535997; c=relaxed/simple; bh=DojTQU3H1Nst4TOASjtnlj6KJbNqkKC/MWTwotqsbJM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HAY4foUH+b/6OgeuVmcRG0YD5FvI6vO8mQ11fL8APDe0heKMspu1UBP2OdFYufg70lThEP0eyfzn7jdiQWQLo9nG4csUuiZRRiA7oc97gsWjjmiAlK5LzJ7tTXwYLv18IVP7/nur3sVyCjSjnHcE4hieLk3rSi42TKLp+ojkMok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=du48YFvG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="du48YFvG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8701BC4CEDD; Wed, 26 Feb 2025 02:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535997; bh=DojTQU3H1Nst4TOASjtnlj6KJbNqkKC/MWTwotqsbJM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=du48YFvGB97pvzgP6YPo0mZTIBk/UTlOll8uqimkxAwbNJKppmMSTFcGa7BtAnG1t sQXutQBvTw+Ltm4c2R8e6hCPlftiQl/nQ8X8qRFEr8+E682bR0h3BP/bnyrE/9oPNN 9X4ljpVP8RyE5DXjBXfVOO7cpqkoz3U64XfUJLQ0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49352: ext4: fix warning in ext4_handle_inode_extension Date: Wed, 26 Feb 2025 03:10:26 +0100 Message-ID: <2025022642-CVE-2022-49352-f7cf@gregkh> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4688; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=DojTQU3H1Nst4TOASjtnlj6KJbNqkKC/MWTwotqsbJM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7yp/Pmn/1dvKT8ldsEpMq/306yR8XGXBcyP+L2/E26 7C85UvUO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAi4hoM8+xW3tKtUnjUXd+7 jW+3QMhj4xVXexkWzD24M4BT5c1l/Q+61zay2388cG4ZFwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: ext4: fix warning in ext4_handle_inode_extension We got issue as follows: EXT4-fs error (device loop0) in ext4_reserve_inode_write:5741: Out of memory EXT4-fs error (device loop0): ext4_setattr:5462: inode #13: comm syz-executor.0: mark_inode_dirty error EXT4-fs error (device loop0) in ext4_setattr:5519: Out of memory EXT4-fs error (device loop0): ext4_ind_map_blocks:595: inode #13: comm syz-executor.0: Can't allocate blocks for non-extent mapped inodes with bigalloc ------------[ cut here ]------------ WARNING: CPU: 1 PID: 4361 at fs/ext4/file.c:301 ext4_file_write_iter+0x11c9/0x1220 Modules linked in: CPU: 1 PID: 4361 Comm: syz-executor.0 Not tainted 5.10.0+ #1 RIP: 0010:ext4_file_write_iter+0x11c9/0x1220 RSP: 0018:ffff924d80b27c00 EFLAGS: 00010282 RAX: ffffffff815a3379 RBX: 0000000000000000 RCX: 000000003b000000 RDX: ffff924d81601000 RSI: 00000000000009cc RDI: 00000000000009cd RBP: 000000000000000d R08: ffffffffbc5a2c6b R09: 0000902e0e52a96f R10: ffff902e2b7c1b40 R11: ffff902e2b7c1b40 R12: 000000000000000a R13: 0000000000000001 R14: ffff902e0e52aa10 R15: ffffffffffffff8b FS: 00007f81a7f65700(0000) GS:ffff902e3bc80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffff600400 CR3: 000000012db88001 CR4: 00000000003706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: do_iter_readv_writev+0x2e5/0x360 do_iter_write+0x112/0x4c0 do_pwritev+0x1e5/0x390 __x64_sys_pwritev2+0x7e/0xa0 do_syscall_64+0x37/0x50 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Above issue may happen as follows: Assume inode.i_size=4096 EXT4_I(inode)->i_disksize=4096 step 1: set inode->i_isize = 8192 ext4_setattr if (attr->ia_size != inode->i_size) EXT4_I(inode)->i_disksize = attr->ia_size; rc = ext4_mark_inode_dirty ext4_reserve_inode_write ext4_get_inode_loc __ext4_get_inode_loc sb_getblk --> return -ENOMEM ... if (!error) ->will not update i_size i_size_write(inode, attr->ia_size); Now: inode.i_size=4096 EXT4_I(inode)->i_disksize=8192 step 2: Direct write 4096 bytes ext4_file_write_iter ext4_dio_write_iter iomap_dio_rw ->return error if (extend) ext4_handle_inode_extension WARN_ON_ONCE(i_size_read(inode) < EXT4_I(inode)->i_disksize); ->Then trigger warning. To solve above issue, if mark inode dirty failed in ext4_setattr just set 'EXT4_I(inode)->i_disksize' with old value. The Linux kernel CVE team has assigned CVE-2022-49352 to this issue. Affected and fixed versions =========================== Fixed in 5.4.198 with commit 0ab308d72af7548f21e4499d025c25887da0c26a Fixed in 5.10.121 with commit adf490083ca52ebfb0b2fe64ff1ead00c0452dd7 Fixed in 5.15.46 with commit b81d2ff6885e38fc745eeaf9565775055778fc0b Fixed in 5.17.14 with commit e383c2aa5f02ab571530dc5c5696479672478c25 Fixed in 5.18.3 with commit 1bcce88da60eccc946c0f4ed942b0f08cd565778 Fixed in 5.19 with commit f4534c9fc94d22383f187b9409abb3f9df2e3db3 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-49352 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: fs/ext4/inode.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/0ab308d72af7548f21e4499d025c25887da0c26a https://git.kernel.org/stable/c/adf490083ca52ebfb0b2fe64ff1ead00c0452dd7 https://git.kernel.org/stable/c/b81d2ff6885e38fc745eeaf9565775055778fc0b https://git.kernel.org/stable/c/e383c2aa5f02ab571530dc5c5696479672478c25 https://git.kernel.org/stable/c/1bcce88da60eccc946c0f4ed942b0f08cd565778 https://git.kernel.org/stable/c/f4534c9fc94d22383f187b9409abb3f9df2e3db3