android_kernel_samsung_sm8650/fs/f2fs
Jaegeuk Kim fd3551098b BACKPORT: f2fs: split initial and dynamic conditions for extent_cache
Let's allocate the extent_cache tree without dynamic conditions to avoid a
missing condition causing a panic as below.

 # create a file w/ a compressed flag
 # disable the compression
 # panic while updating extent_cache

F2FS-fs (dm-64): Swapfile: last extent is not aligned to section
F2FS-fs (dm-64): Swapfile (3) is not align to section: 1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate(2097152 * N)
Adding 124996k swap on ./swap-file.  Priority:0 extents:2 across:17179494468k
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline]
BUG: KASAN: null-ptr-deref in atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline]
BUG: KASAN: null-ptr-deref in queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline]
BUG: KASAN: null-ptr-deref in __raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline]
BUG: KASAN: null-ptr-deref in _raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295
Write of size 4 at addr 0000000000000030 by task syz-executor154/3327

CPU: 0 PID: 3327 Comm: syz-executor154 Tainted: G           O      5.10.185 #1
Hardware name: emulation qemu-x86/qemu-x86, BIOS 2023.01-21885-gb3cc1cd24d 01/01/2023
Call Trace:
 __dump_stack out/common/lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x17e/0x1c4 out/common/lib/dump_stack.c:118
 __kasan_report+0x16c/0x260 out/common/mm/kasan/report.c:415
 kasan_report+0x51/0x70 out/common/mm/kasan/report.c:428
 kasan_check_range+0x2f3/0x340 out/common/mm/kasan/generic.c:186
 __kasan_check_write+0x14/0x20 out/common/mm/kasan/shadow.c:37
 instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline]
 atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline]
 queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline]
 __raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline]
 _raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295
 __drop_extent_tree+0xdf/0x2f0 out/common/fs/f2fs/extent_cache.c:1155
 f2fs_drop_extent_tree+0x17/0x30 out/common/fs/f2fs/extent_cache.c:1172
 f2fs_insert_range out/common/fs/f2fs/file.c:1600 [inline]
 f2fs_fallocate+0x19fd/0x1f40 out/common/fs/f2fs/file.c:1764
 vfs_fallocate+0x514/0x9b0 out/common/fs/open.c:310
 ksys_fallocate out/common/fs/open.c:333 [inline]
 __do_sys_fallocate out/common/fs/open.c:341 [inline]
 __se_sys_fallocate out/common/fs/open.c:339 [inline]
 __x64_sys_fallocate+0xb8/0x100 out/common/fs/open.c:339
 do_syscall_64+0x35/0x50 out/common/arch/x86/entry/common.c:46

Bug: 323236756
Cc: stable@vger.kernel.org
Fixes: 72840cccc0a1 ("f2fs: allocate the extent_cache by default")
Reported-and-tested-by: syzbot+d342e330a37b48c094b7@syzkaller.appspotmail.com
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit f803982190f0265fd36cf84670aa6daefc2b0768)
Change-Id: I584b9e37a4790baf5f6613778365b90f128bb765
2024-03-13 08:50:38 +00:00
..
acl.c f2fs: port to vfs{g,u}id_t and associated helpers 2022-10-04 13:31:43 -07:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c FROMGIT: f2fs: introduce FAULT_BLKADDR_CONSISTENCE 2024-03-04 18:26:14 +00:00
compress.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
data.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
debug.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
dir.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
extent_cache.c BACKPORT: f2fs: split initial and dynamic conditions for extent_cache 2024-03-13 08:50:38 +00:00
f2fs.h Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
file.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
gc.c f2fs: optimize iteration over sparse directories 2023-10-06 14:56:44 +02:00
gc.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c This is the 6.1.54 stable release 2023-10-17 12:03:09 +00:00
inode.c BACKPORT: f2fs: Support Block Size == Page Size 2024-02-07 00:14:26 +00:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:55:21 +01:00
iostat.h f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx() 2023-02-07 10:54:25 -08:00
Kconfig f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem 2022-03-04 09:15:53 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
node.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
node.h f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
recovery.c f2fs: fix to recover quota data correctly 2023-04-12 08:56:26 -07:00
segment.c FROMGIT: f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode 2024-03-04 18:26:14 +00:00
segment.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
shrinker.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
super.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
sysfs.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:55:18 +01:00
xattr.c Revert "Merge tag 'android14-6.1.75_r00' into android14-6.1" 2024-03-07 21:18:27 +00:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00