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 CAC041E1A2D for ; Wed, 16 Apr 2025 14:18:40 +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=1744813121; cv=none; b=FirFNGKmZ765ZZLWZpGC8lHyyWdFeuNoCST3rJ4eZNXDaGtTLzY2wMLVJPAiYyDWsWCKJh0tL6/RSZtwVMJPC9XUdS8Ohhn5DfJdlQ5VlZaP+G8uCBWOYlZ+IS5gkHC4SnC2D6rW9G/36bab0A9QVDiu42UWN6A8uE/g4ctHvvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744813121; c=relaxed/simple; bh=bxPT2YVZs24oUl2tu77ryfptgBzRtN2H39N2OLqQmH8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JRQk3ylA7jRmk4gHNfqfb7mIWHeEWbTn+wOPEqaYMl29FMRDEhNCXFqFxWidVPOwbvOZISTqc0hYnEKrw6JUbxlxzGoO/ZV6tavO+/E+mf+ewM5ZjwL6Cpd2oT2zdMwSOut3TgoZVr8QQBVPK2H1qADU/8z4SioTb5IB1zPchYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zAnxTmlJ; 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="zAnxTmlJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C46B6C4CEEC; Wed, 16 Apr 2025 14:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744813120; bh=bxPT2YVZs24oUl2tu77ryfptgBzRtN2H39N2OLqQmH8=; h=From:To:Cc:Subject:Date:Reply-to:From; b=zAnxTmlJw+nOrk5QVI/2SsXiNArELLj2+lOgWzP+ogXMRWg6cUz5bK3OGa9Scwl7+ SBJncCtBpJSejbiIGMOyzSH9xATiSq04LT5VYkSzwlvMOfeWZhcAnexnbx+E5HZuUQ skvtxSIsIV7ktO9U/qZ2FseRGaNH+eeEuQwZQl6M= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-22123: f2fs: fix to avoid accessing uninitialized curseg Date: Wed, 16 Apr 2025 16:13:34 +0200 Message-ID: <2025041628-CVE-2025-22123-5ca9@gregkh> X-Mailer: git-send-email 2.49.0 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=3870; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=bxPT2YVZs24oUl2tu77ryfptgBzRtN2H39N2OLqQmH8=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn/d50x41TIKIgJuBegcG7D3XlzDRMPdSnNiRDvXb7NY dbuy4U2HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRLl6GBXOmMk2ycLtV2vCa daWZyaa+nesmbGZYMMlq+ef572x9H6w/svRR7DvPM0HN8wE= 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 avoid accessing uninitialized curseg syzbot reports a f2fs bug as below: F2FS-fs (loop3): Stopped filesystem due to reason: 7 kworker/u8:7: attempt to access beyond end of device BUG: unable to handle page fault for address: ffffed1604ea3dfa RIP: 0010:get_ckpt_valid_blocks fs/f2fs/segment.h:361 [inline] RIP: 0010:has_curseg_enough_space fs/f2fs/segment.h:570 [inline] RIP: 0010:__get_secs_required fs/f2fs/segment.h:620 [inline] RIP: 0010:has_not_enough_free_secs fs/f2fs/segment.h:633 [inline] RIP: 0010:has_enough_free_secs+0x575/0x1660 fs/f2fs/segment.h:649 f2fs_is_checkpoint_ready fs/f2fs/segment.h:671 [inline] f2fs_write_inode+0x425/0x540 fs/f2fs/inode.c:791 write_inode fs/fs-writeback.c:1525 [inline] __writeback_single_inode+0x708/0x10d0 fs/fs-writeback.c:1745 writeback_sb_inodes+0x820/0x1360 fs/fs-writeback.c:1976 wb_writeback+0x413/0xb80 fs/fs-writeback.c:2156 wb_do_writeback fs/fs-writeback.c:2303 [inline] wb_workfn+0x410/0x1080 fs/fs-writeback.c:2343 process_one_work kernel/workqueue.c:3236 [inline] process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3317 worker_thread+0x870/0xd30 kernel/workqueue.c:3398 kthread+0x7a9/0x920 kernel/kthread.c:464 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Commit 8b10d3653735 ("f2fs: introduce FAULT_NO_SEGMENT") allows to trigger no free segment fault in allocator, then it will update curseg->segno to NULL_SEGNO, though, CP_ERROR_FLAG has been set, f2fs_write_inode() missed to check the flag, and access invalid curseg->segno directly in below call path, then resulting in panic: - f2fs_write_inode - f2fs_is_checkpoint_ready - has_enough_free_secs - has_not_enough_free_secs - __get_secs_required - has_curseg_enough_space - get_ckpt_valid_blocks : access invalid curseg->segno To avoid this issue, let's: - check CP_ERROR_FLAG flag in prior to f2fs_is_checkpoint_ready() in f2fs_write_inode(). - in has_curseg_enough_space(), save curseg->segno into a temp variable, and verify its validation before use. The Linux kernel CVE team has assigned CVE-2025-22123 to this issue. Affected and fixed versions =========================== Issue introduced in 6.9 with commit 8b10d3653735e117bc1954ade80d75ad7b46b801 and fixed in 6.14.2 with commit 7f90e5d423cd2d4c74b2abb527872f335108637f Issue introduced in 6.9 with commit 8b10d3653735e117bc1954ade80d75ad7b46b801 and fixed in 6.15-rc1 with commit 986c50f6bca109c6cf362b4e2babcb85aba958f6 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-2025-22123 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/inode.c fs/f2fs/segment.h 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/7f90e5d423cd2d4c74b2abb527872f335108637f https://git.kernel.org/stable/c/986c50f6bca109c6cf362b4e2babcb85aba958f6