linux/fs/f2fs
Chao Yu 4560db9678 f2fs: fix return value of f2fs_recover_fsync_data()
commit 01fba45dea upstream.

With below scripts, it will trigger panic in f2fs:

mkfs.f2fs -f /dev/vdd
mount /dev/vdd /mnt/f2fs
touch /mnt/f2fs/foo
sync
echo 111 >> /mnt/f2fs/foo
f2fs_io fsync /mnt/f2fs/foo
f2fs_io shutdown 2 /mnt/f2fs
umount /mnt/f2fs
mount -o ro,norecovery /dev/vdd /mnt/f2fs
or
mount -o ro,disable_roll_forward /dev/vdd /mnt/f2fs

F2FS-fs (vdd): f2fs_recover_fsync_data: recovery fsync data, check_only: 0
F2FS-fs (vdd): Mounted with checkpoint version = 7f5c361f
F2FS-fs (vdd): Stopped filesystem due to reason: 0
F2FS-fs (vdd): f2fs_recover_fsync_data: recovery fsync data, check_only: 1
Filesystem f2fs get_tree() didn't set fc->root, returned 1
------------[ cut here ]------------
kernel BUG at fs/super.c:1761!
Oops: invalid opcode: 0000 [#1] SMP PTI
CPU: 3 UID: 0 PID: 722 Comm: mount Not tainted 6.18.0-rc2+ #721 PREEMPT(voluntary)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:vfs_get_tree.cold+0x18/0x1a
Call Trace:
 <TASK>
 fc_mount+0x13/0xa0
 path_mount+0x34e/0xc50
 __x64_sys_mount+0x121/0x150
 do_syscall_64+0x84/0x800
 entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fa6cc126cfe

The root cause is we missed to handle error number returned from
f2fs_recover_fsync_data() when mounting image w/ ro,norecovery or
ro,disable_roll_forward mount option, result in returning a positive
error number to vfs_get_tree(), fix it.

Cc: stable@kernel.org
Fixes: 6781eabba1 ("f2fs: give -EINVAL for norecovery and rw mount")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-02 12:57:18 +01:00
..
acl.c f2fs: Pass a folio to f2fs_getxattr() 2025-04-28 15:26:42 +00:00
acl.h f2fs: Pass folios to f2fs_init_acl() 2025-04-28 15:26:41 +00:00
checkpoint.c f2fs: add time stats of checkpoint for debug 2025-08-11 17:03:27 +00:00
compress.c f2fs: fix to avoid potential deadlock 2026-01-02 12:57:17 +01:00
data.c f2fs: fix to avoid updating compression context during writeback 2026-01-02 12:57:16 +01:00
debug.c f2fs: introduce is_cur{seg,sec}() 2025-07-09 18:02:20 +00:00
dir.c f2fs: add lookup_mode mount option 2025-08-11 17:03:27 +00:00
extent_cache.c f2fs: fix age extent cache insertion skip on counter overflow 2026-01-02 12:57:17 +01:00
f2fs.h f2fs: fix age extent cache insertion skip on counter overflow 2026-01-02 12:57:17 +01:00
file.c f2fs: fix to avoid updating zero-sized extent in extent cache 2026-01-02 12:57:17 +01:00
gc.c f2fs: fix uninitialized one_time_gc in victim_sel_policy 2026-01-02 12:57:17 +01:00
gc.h f2fs: add gc_boost_gc_greedy sysfs node 2025-07-29 15:02:36 +00:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: Add folio counterparts to page_private_flags functions 2025-07-22 15:57:05 +00:00
inode.c f2fs: drop inode from the donation list when the last file is closed 2025-07-30 17:13:12 +00:00
iostat.c f2fs: add async reset zone command support 2023-06-12 13:04:09 -07:00
iostat.h f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx() 2023-02-07 10:39:28 -08:00
Kconfig f2fs: switch to using the crc32 library 2024-12-01 17:23:02 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: invalidate dentry cache on failed whiteout creation 2026-01-02 12:57:17 +01:00
node.c f2fs: avoid unnecessary folio_clear_uptodate() for cleanup 2025-09-09 03:26:41 +00:00
node.h f2fs: fix to do sanity check on node footer for non inode dnode 2025-08-28 00:09:01 +00:00
recovery.c f2fs: fix to detect recoverable inode during dryrun of find_fsync_dnodes() 2026-01-02 12:57:18 +01:00
segment.c f2fs: fix age extent cache insertion skip on counter overflow 2026-01-02 12:57:17 +01:00
segment.h f2fs: fix to not account invalid blocks in get_left_section_blocks() 2026-01-02 12:57:18 +01:00
shrinker.c f2fs: handle error cases of memory donation 2025-05-06 15:46:55 +00:00
super.c f2fs: fix return value of f2fs_recover_fsync_data() 2026-01-02 12:57:18 +01:00
sysfs.c f2fs: revert summary entry count from 2048 to 512 in 16kb block support 2025-12-18 14:03:35 +01:00
verity.c f2fs: move verity info pointer to fs-specific part of inode 2025-08-21 13:58:08 +02:00
xattr.c f2fs: use global inline_xattr_slab instead of per-sb slab cache 2026-01-02 12:57:17 +01:00
xattr.h f2fs: use global inline_xattr_slab instead of per-sb slab cache 2026-01-02 12:57:17 +01:00