In the Linux kernel, the following vulnerability has been resolved:
f2fs: don't reset unchangable mount option in f2fs_remount()
syzbot reports a bug as below:
general protection fault, probably for non-canonical address 0xdffffc0000000009: 0000 [#1] PREEMPT SMP KASAN
RIP: 0010:__lock_acquire+0x69/0x2000kernel/locking/lockdep.c:4942Call Trace:lock_acquire+0x1e3/0x520kernel/locking/lockdep.c:5691__raw_write_lockinclude/linux/rwlock_api_smp.h:209[inline]_raw_write_lock+0x2e/0x40kernel/locking/spinlock.c:300__drop_extent_tree+0x3ac/0x660fs/f2fs/extent_cache.c:1100f2fs_drop_extent_tree+0x17/0x30fs/f2fs/extent_cache.c:1116f2fs_insert_range+0x2d5/0x3c0fs/f2fs/file.c:1664f2fs_fallocate+0x4e4/0x6d0fs/f2fs/file.c:1838vfs_fallocate+0x54b/0x6b0fs/open.c:324ksys_fallocatefs/open.c:347[inline]__do_sys_fallocatefs/open.c:355[inline]__se_sys_fallocatefs/open.c:353[inline]__x64_sys_fallocate+0xbd/0x100fs/open.c:353do_syscall_x64arch/x86/entry/common.c:50[inline]do_syscall_64+0x41/0xc0arch/x86/entry/common.c:80entry_SYSCALL_64_after_hwframe+0x63/0xcd
The root cause is race condition as below:
- since it tries to remount rw filesystem, so that do_remount won't
call sb_prepare_remount_readonly to block fallocate, there may be race
condition in between remount and fallocate.
- in f2fs_remount(), default_options() will reset mount option to default
one, and then update it based on result of parse_options(), so there is
a hole which race condition can happen.