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 5768419E999 for ; Wed, 26 Feb 2025 01:59:03 +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=1740535143; cv=none; b=evt0a7zaS40/EQH3cWWsxxsaM2BhWH9D1CzDPRbzlBc+gsdOwnFf2XSGTjBXojf4Sh6L2isEvGXPyCtXxmhiEL+noIo+yzPbkBcbPYyhHisuaMK+Gun6YYXoWdDNKPGL6XulwjsBzq7rF16I8QPPr6tCrSRPpKReF+h4rPyj0yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535143; c=relaxed/simple; bh=0npidyVtvY306+DCbNIFCEXjGRX5NhwsWDi2gPgMtT0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CZfzovWbl9FCwxYKbfP8vS5MMbpiH0+iL5I5b7y/Xz2Lc7kqMHD/UhaYQoeEWZFm/x1g0CXIFqtV2EVL19eBXCg5PZxpq+ZwlPR9Niawj5C3fnkMQCBfPeAFCAc+CFGSWorzKrMXS8j1YpLMMT6hkBNhlokc+OkkgVmBWsdGqDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Q3ZJImmF; 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="Q3ZJImmF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE87C4CEE7; Wed, 26 Feb 2025 01:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535143; bh=0npidyVtvY306+DCbNIFCEXjGRX5NhwsWDi2gPgMtT0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Q3ZJImmFpWKWCjmomo6crw0DUJvQcaODmUQV5APx3sb4nJHZEhBzUmBnBGe9ewr/9 O/q7xOVpabT+LXJLBUNSBdkXUo6E5j52rmiYaRJuW+A/+sUvlQOPAULog70grCK7pf JcYtwA+cHpsVt2BlDCSmz9F19OD29HRtEnWIiHKg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49170: f2fs: fix to do sanity check on curseg->alloc_type Date: Wed, 26 Feb 2025 02:56:15 +0100 Message-ID: <2025022612-CVE-2022-49170-b183@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=4115; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=0npidyVtvY306+DCbNIFCEXjGRX5NhwsWDi2gPgMtT0=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SlyCniRmiJm+lZ6ulxt89+zF5Wo1khHTNvIpyeox/ U+OV7PqiGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgIlsO8+woGlP0mU9h4QDaz5X 119Om7f4T+jbxwzzy5/xJL5m+62+92LnplPzr2dunucVBgA= 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: f2fs: fix to do sanity check on curseg->alloc_type As Wenqing Liu reported in bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215657 - Overview UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2 when mount and operate a corrupted image - Reproduce tested on kernel 5.17-rc4, 5.17-rc6 1. mkdir test_crash 2. cd test_crash 3. unzip tmp2.zip 4. mkdir mnt 5. ./single_test.sh f2fs 2 - Kernel dump [ 46.434454] loop0: detected capacity change from 0 to 131072 [ 46.529839] F2FS-fs (loop0): Mounted with checkpoint version = 7548c2d9 [ 46.738319] ================================================================================ [ 46.738412] UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2 [ 46.738475] index 231 is out of range for type 'unsigned int [2]' [ 46.738539] CPU: 2 PID: 939 Comm: umount Not tainted 5.17.0-rc6 #1 [ 46.738547] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 46.738551] Call Trace: [ 46.738556] [ 46.738563] dump_stack_lvl+0x47/0x5c [ 46.738581] ubsan_epilogue+0x5/0x50 [ 46.738592] __ubsan_handle_out_of_bounds+0x68/0x80 [ 46.738604] f2fs_allocate_data_block+0xdff/0xe60 [f2fs] [ 46.738819] do_write_page+0xef/0x210 [f2fs] [ 46.738934] f2fs_do_write_node_page+0x3f/0x80 [f2fs] [ 46.739038] __write_node_page+0x2b7/0x920 [f2fs] [ 46.739162] f2fs_sync_node_pages+0x943/0xb00 [f2fs] [ 46.739293] f2fs_write_checkpoint+0x7bb/0x1030 [f2fs] [ 46.739405] kill_f2fs_super+0x125/0x150 [f2fs] [ 46.739507] deactivate_locked_super+0x60/0xc0 [ 46.739517] deactivate_super+0x70/0xb0 [ 46.739524] cleanup_mnt+0x11a/0x200 [ 46.739532] __cleanup_mnt+0x16/0x20 [ 46.739538] task_work_run+0x67/0xa0 [ 46.739547] exit_to_user_mode_prepare+0x18c/0x1a0 [ 46.739559] syscall_exit_to_user_mode+0x26/0x40 [ 46.739568] do_syscall_64+0x46/0xb0 [ 46.739584] entry_SYSCALL_64_after_hwframe+0x44/0xae The root cause is we missed to do sanity check on curseg->alloc_type, result in out-of-bound accessing on sbi->block_count[] array, fix it. The Linux kernel CVE team has assigned CVE-2022-49170 to this issue. Affected and fixed versions =========================== Fixed in 5.10.110 with commit 498b7088db71f9707359448cd6800bbb1882f4c3 Fixed in 5.15.33 with commit f68caedf264a95c0b02dfd0d9f92ac2637d5848a Fixed in 5.16.19 with commit 0748a0f7dcb9d9dddc80302d73ebcecef6782ef0 Fixed in 5.17.2 with commit c12765e3f129b144421c80d3383df885f85ee290 Fixed in 5.18 with commit f41ee8b91c00770d718be2ff4852a80017ae9ab3 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-49170 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/f2fs/segment.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/498b7088db71f9707359448cd6800bbb1882f4c3 https://git.kernel.org/stable/c/f68caedf264a95c0b02dfd0d9f92ac2637d5848a https://git.kernel.org/stable/c/0748a0f7dcb9d9dddc80302d73ebcecef6782ef0 https://git.kernel.org/stable/c/c12765e3f129b144421c80d3383df885f85ee290 https://git.kernel.org/stable/c/f41ee8b91c00770d718be2ff4852a80017ae9ab3