android_kernel_xiaomi_sm8450/fs/f2fs
Jaegeuk Kim e0ab5345d6 UPSTREAM: f2fs: avoid false alarm of circular locking
======================================================
WARNING: possible circular locking dependency detected
6.5.0-rc5-syzkaller-00353-gae545c3283dc #0 Not tainted
------------------------------------------------------
syz-executor273/5027 is trying to acquire lock:
ffff888077fe1fb0 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
ffff888077fe1fb0 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_add_inline_entry+0x300/0x6f0 fs/f2fs/inline.c:644

but task is already holding lock:
ffff888077fe07c8 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
ffff888077fe07c8 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_add_dentry+0x92/0x230 fs/f2fs/dir.c:783

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #1 (&fi->i_xattr_sem){.+.+}-{3:3}:
       down_read+0x9c/0x470 kernel/locking/rwsem.c:1520
       f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
       f2fs_getxattr+0xb1e/0x12c0 fs/f2fs/xattr.c:532
       __f2fs_get_acl+0x5a/0x900 fs/f2fs/acl.c:179
       f2fs_acl_create fs/f2fs/acl.c:377 [inline]
       f2fs_init_acl+0x15c/0xb30 fs/f2fs/acl.c:420
       f2fs_init_inode_metadata+0x159/0x1290 fs/f2fs/dir.c:558
       f2fs_add_regular_entry+0x79e/0xb90 fs/f2fs/dir.c:740
       f2fs_add_dentry+0x1de/0x230 fs/f2fs/dir.c:788
       f2fs_do_add_link+0x190/0x280 fs/f2fs/dir.c:827
       f2fs_add_link fs/f2fs/f2fs.h:3554 [inline]
       f2fs_mkdir+0x377/0x620 fs/f2fs/namei.c:781
       vfs_mkdir+0x532/0x7e0 fs/namei.c:4117
       do_mkdirat+0x2a9/0x330 fs/namei.c:4140
       __do_sys_mkdir fs/namei.c:4160 [inline]
       __se_sys_mkdir fs/namei.c:4158 [inline]
       __x64_sys_mkdir+0xf2/0x140 fs/namei.c:4158
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&fi->i_sem){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3142 [inline]
       check_prevs_add kernel/locking/lockdep.c:3261 [inline]
       validate_chain kernel/locking/lockdep.c:3876 [inline]
       __lock_acquire+0x2e3d/0x5de0 kernel/locking/lockdep.c:5144
       lock_acquire kernel/locking/lockdep.c:5761 [inline]
       lock_acquire+0x1ae/0x510 kernel/locking/lockdep.c:5726
       down_write+0x93/0x200 kernel/locking/rwsem.c:1573
       f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
       f2fs_add_inline_entry+0x300/0x6f0 fs/f2fs/inline.c:644
       f2fs_add_dentry+0xa6/0x230 fs/f2fs/dir.c:784
       f2fs_do_add_link+0x190/0x280 fs/f2fs/dir.c:827
       f2fs_add_link fs/f2fs/f2fs.h:3554 [inline]
       f2fs_mkdir+0x377/0x620 fs/f2fs/namei.c:781
       vfs_mkdir+0x532/0x7e0 fs/namei.c:4117
       ovl_do_mkdir fs/overlayfs/overlayfs.h:196 [inline]
       ovl_mkdir_real+0xb5/0x370 fs/overlayfs/dir.c:146
       ovl_workdir_create+0x3de/0x820 fs/overlayfs/super.c:309
       ovl_make_workdir fs/overlayfs/super.c:711 [inline]
       ovl_get_workdir fs/overlayfs/super.c:864 [inline]
       ovl_fill_super+0xdab/0x6180 fs/overlayfs/super.c:1400
       vfs_get_super+0xf9/0x290 fs/super.c:1152
       vfs_get_tree+0x88/0x350 fs/super.c:1519
       do_new_mount fs/namespace.c:3335 [inline]
       path_mount+0x1492/0x1ed0 fs/namespace.c:3662
       do_mount fs/namespace.c:3675 [inline]
       __do_sys_mount fs/namespace.c:3884 [inline]
       __se_sys_mount fs/namespace.c:3861 [inline]
       __x64_sys_mount+0x293/0x310 fs/namespace.c:3861
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(&fi->i_xattr_sem);
                               lock(&fi->i_sem);
                               lock(&fi->i_xattr_sem);
  lock(&fi->i_sem);

Bug: 349265158
Change-Id: I4d9a7107b45eb81ea4d9b0cdc65333ec0aeb26b1
Cc: <stable@vger.kernel.org>
Reported-and-tested-by: syzbot+e5600587fa9cbf8e3826@syzkaller.appspotmail.com
Fixes: 5eda1ad1aaff "f2fs: fix deadlock in i_xattr_sem and inode page lock"
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sayali Lokhande <quic_sayalil@quicinc.com>
(cherry picked from commit 5c13e2388bf3426fd69a89eb46e50469e9624e56)
2024-07-19 22:10:37 +00:00
..
acl.c
acl.h
checkpoint.c Merge 5.10.181 into android12-5.10-lts 2023-06-27 08:23:11 +00:00
compress.c This is the 5.10.202 stable release 2023-12-08 16:26:36 +00:00
data.c UPSTREAM: f2fs: fix to avoid use-after-free for cached IPU bio 2023-06-29 13:13:11 +00:00
debug.c BACKPORT: f2fs: introduce gc_urgent_mid mode 2023-05-03 08:56:49 +00:00
dir.c UPSTREAM: f2fs: fix deadlock in i_xattr_sem and inode page lock 2024-07-19 22:10:37 +00:00
extent_cache.c FROMGIT: f2fs: split initial and dynamic conditions for extent_cache 2023-09-20 08:50:12 -07:00
f2fs.h UPSTREAM: f2fs: avoid false alarm of circular locking 2024-07-19 22:10:37 +00:00
file.c Merge 5.10.214 into android12-5.10-lts 2024-05-15 16:03:24 +00:00
gc.c This is the 5.10.200 stable release 2023-11-26 14:07:49 +00:00
gc.h
hash.c BACKPORT: f2fs: don't use casefolded comparison for "." and ".." 2022-11-16 14:48:59 +00:00
inline.c UPSTREAM: f2fs: avoid false alarm of circular locking 2024-07-19 22:10:37 +00:00
inode.c BACKPORT: f2fs: fix to do sanity check on extent cache correctly 2023-09-08 12:39:56 +01:00
Kconfig
Makefile
namei.c This is the 5.10.209 stable release 2024-01-27 03:00:58 +00:00
node.c This is the 5.10.188 stable release 2023-08-03 11:23:27 +00:00
node.h BACKPORT: f2fs: add block_age-based extent cache 2023-01-10 18:49:35 +00:00
recovery.c This is the 5.10.210 stable release 2024-04-10 07:10:03 +00:00
segment.c Merge adc2d82eee ("crypto: sa2ul - Select CRYPTO_DES") into android12-5.10-lts 2023-06-25 11:41:48 +00:00
segment.h Merge adc2d82eee ("crypto: sa2ul - Select CRYPTO_DES") into android12-5.10-lts 2023-06-25 11:41:48 +00:00
shrinker.c BACKPORT: f2fs: add block_age-based extent cache 2023-01-10 18:49:35 +00:00
super.c BACKPORT: f2fs: don't reset unchangable mount option in f2fs_remount() 2023-09-06 09:56:37 +00:00
sysfs.c Merge 5.10.184 into android12-5.10-lts 2023-06-28 07:16:23 +00:00
verity.c This is the 5.10.173 stable release 2023-03-22 11:21:35 +00:00
xattr.c UPSTREAM: f2fs: fix deadlock in i_xattr_sem and inode page lock 2024-07-19 22:10:37 +00:00
xattr.h