From mboxrd@z Thu Jan 1 00:00:00 1970 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 1C3C5367298 for ; Tue, 12 May 2026 21:34:30 +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=1778621671; cv=none; b=keGX8h4JFsI2DNVvm36I4AZkloiybe8fVvuOgsAjID1R8pjTfPyytLKNiJxD/zqn3pNwRkkZWdhtuGRrIiIBr3IdHm90SOOQeizH6oHM2vyKFujT4qqGEf9FFEcKy8YbAu35NpFj0gVtxs0BWw7DvR/VU2ZHndhdfzkUwChSXxQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778621671; c=relaxed/simple; bh=dUIrlMfq7Obpx07FQFhh53P2qigtnkV4RssU0uS0xPQ=; h=Date:To:From:Subject:Message-Id; b=HsQmjs2KvaUdZ1pu37sUlqncTaww+lQ+vbXv378lunYAygeP3dohCtJqVD5gpZWc3m4Qtjg6G+nzQFZo0cIlg4Zso8Iq9dR5GCcfrggaW1y4j9R0MNaMNvmKf9mvzqaJ8u8Ey8++Lyzr624JWAC3Wm4/I4ymyXyYNqU8gDUQRc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=AHIEEpW5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="AHIEEpW5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0665C2BCB0; Tue, 12 May 2026 21:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1778621670; bh=dUIrlMfq7Obpx07FQFhh53P2qigtnkV4RssU0uS0xPQ=; h=Date:To:From:Subject:From; b=AHIEEpW5zv5QrY0oBEKLHGsufreBQMum81kpomI+ER4Lgp0p2EErh1Kw+Ivduidj5 aaMPJ6fDHoc/8FMSH+36y5QzIM2wNFfJ9PmlJ85lJtGRqq54/CYyZ1HDhxzaMFRdJN X+yFICYY1cKkK5R6JYm1ETJUYnYpxGpc8a6/BPqc= Date: Tue, 12 May 2026 14:34:30 -0700 To: mm-commits@vger.kernel.org,piaojun@huawei.com,mark@fasheh.com,junxiao.bi@oracle.com,joseph.qi@linux.alibaba.com,jlbec@evilplan.org,heming.zhao@suse.com,gechangwei@live.cn,gality369@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + ocfs2-dont-bug_on-an-invalid-journal-dinode.patch added to mm-nonmm-unstable branch Message-Id: <20260512213430.C0665C2BCB0@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: ocfs2: don't BUG_ON an invalid journal dinode has been added to the -mm mm-nonmm-unstable branch. Its filename is ocfs2-dont-bug_on-an-invalid-journal-dinode.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ocfs2-dont-bug_on-an-invalid-journal-dinode.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: ZhengYuan Huang Subject: ocfs2: don't BUG_ON an invalid journal dinode Date: Tue, 12 May 2026 10:41:15 +0800 [BUG] A fuzzed OCFS2 image can corrupt the current slot journal dinode while mount is still in progress. The mount path first reports the invalid journal block and then crashes in shutdown: kernel BUG at fs/ocfs2/journal.c:1034! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:ocfs2_journal_toggle_dirty+0x2d6/0x340 fs/ocfs2/journal.c:1034 Call Trace: ocfs2_journal_shutdown+0x414/0xc30 fs/ocfs2/journal.c:1116 ocfs2_mount_volume fs/ocfs2/super.c:1785 [inline] ocfs2_fill_super+0x30a9/0x3cd0 fs/ocfs2/super.c:1083 get_tree_bdev_flags+0x38b/0x640 fs/super.c:1698 get_tree_bdev+0x24/0x40 fs/super.c:1721 ocfs2_get_tree+0x21/0x30 fs/ocfs2/super.c:1184 vfs_get_tree+0x9a/0x370 fs/super.c:1758 fc_mount fs/namespace.c:1199 [inline] do_new_mount_fc fs/namespace.c:3642 [inline] do_new_mount fs/namespace.c:3718 [inline] path_mount+0x5b8/0x1ea0 fs/namespace.c:4028 do_mount fs/namespace.c:4041 [inline] __do_sys_mount fs/namespace.c:4229 [inline] __se_sys_mount fs/namespace.c:4206 [inline] __x64_sys_mount+0x282/0x320 fs/namespace.c:4206 ... [CAUSE] ocfs2_journal_toggle_dirty() used to return -EIO when journal->j_bh no longer contained a valid dinode, because the startup and shutdown paths already handled that failure. Commit 10995aa2451a ("ocfs2: Morph the haphazard OCFS2_IS_VALID_DINODE() checks.") changed the check to a BUG_ON() under the assumption that the journal dinode had already been validated. That turns an unexpected invalid journal dinode during mount teardown into a kernel crash instead of a normal mount failure. [FIX] Replace the BUG_ON() with WARN_ON() and return -EIO. This keeps the invariant warning for debugging, but restores the original behavior of failing startup or shutdown cleanly instead of panicking the kernel. Link: https://lore.kernel.org/20260512024115.4036371-1-gality369@gmail.com Fixes: 10995aa2451a ("ocfs2: Morph the haphazard OCFS2_IS_VALID_DINODE() checks.") Signed-off-by: ZhengYuan Huang Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Signed-off-by: Andrew Morton --- fs/ocfs2/journal.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/fs/ocfs2/journal.c~ocfs2-dont-bug_on-an-invalid-journal-dinode +++ a/fs/ocfs2/journal.c @@ -1022,11 +1022,8 @@ static int ocfs2_journal_toggle_dirty(st struct ocfs2_dinode *fe; fe = (struct ocfs2_dinode *)bh->b_data; - - /* The journal bh on the osb always comes from ocfs2_journal_init() - * and was validated there inside ocfs2_inode_lock_full(). It's a - * code bug if we mess it up. */ - BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); + if (WARN_ON(!OCFS2_IS_VALID_DINODE(fe))) + return -EIO; flags = le32_to_cpu(fe->id1.journal1.ij_flags); if (dirty) _ Patches currently in -mm which might be from gality369@gmail.com are ocfs2-reject-inconsistent-inode-size-before-truncate.patch ocfs2-dont-bug_on-an-invalid-journal-dinode.patch