During mount, ocfs2_initialize_super() loads the root directory, system directory, and global system inodes via ocfs2_init_global_system_inodes(). Since commit a8a986db6493 ("ocfs2: ocfs2_initialize_super does cleanup job before return error"), it assumes none stay loaded if that helper fails, jumping to out_dlm_out past ocfs2_release_system_inodes(): status = ocfs2_init_global_system_inodes(osb); if (status < 0) { mlog_errno(status); goto out_dlm_out; } In ocfs2_init_global_system_inodes(), ocfs2_iget() first loads the root inode at s_root_blkno, hashes it in the VFS inode cache under (sb, i_ino), and saves it in osb->root_inode. If ocfs2_iget() then fails on a corrupt or unreadable s_system_dir_blkno block, the function jumps to bail without calling ocfs2_release_system_inodes(), never passing root_inode to iput(). Because the mount fails before sb->s_root is set, generic_shutdown_super() skips its sb->s_root teardown and busy-inode poisoning, freeing sb while osb->root_inode stays hashed. When a later mount reuses that super_block address, iget_locked() on the same inode number returns the stale OCFS2 inode attached to the new filesystem's superblock. VFS operations on that file then run OCFS2 callbacks against the new filesystem's s_fs_info, corrupting foreign superblock memory or crashing the kernel (for example, openat() hits spinlock bad magic and an oops in ocfs2_permission() when locking osb->osb_lock). Triggering this requires CAP_SYS_ADMIN to mount a corrupted OCFS2 volume and a second filesystem. Call ocfs2_release_system_inodes() when loading s_system_dir_blkno fails in ocfs2_init_global_system_inodes(), matching the cleanup in the global system inode loop below so failed calls leave no system inodes behind. Fixes: a8a986db6493 ("ocfs2: ocfs2_initialize_super does cleanup job before return error") Closes: https://lore.kernel.org/lkml/CANypQFYAkHt6ARjeVAEb7pBeAroaHhqVm_1BL6gqQdKV4rAv1Q@mail.gmail.com/ Cc: stable@vger.kernel.org Assisted-by: Antigravity:Gemini Signed-off-by: Jiaming Zhang --- fs/ocfs2/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index d2021405d408..1a8ff5d0f560 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -449,6 +449,7 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) new = ocfs2_iget(osb, osb->system_dir_blkno, OCFS2_FI_FLAG_SYSFILE, 0); if (IS_ERR(new)) { + ocfs2_release_system_inodes(osb); status = PTR_ERR(new); mlog_errno(status); goto bail; base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.43.0