[syzbot] [f2fs?] possible deadlock in f2fs_getxattr

10 views
Skip to first unread message

syzbot

unread,
Jul 7, 2023, 12:06:55 AM7/7/23
to ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: a452483508d7 Merge tag 's390-6.5-2' of git://git.kernel.or..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=161917a0a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=15873d91ff37a949
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5a4997524374/disk-a4524835.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a0d32791e67c/vmlinux-a4524835.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ff545ba23349/bzImage-a4524835.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e56005...@syzkaller.appspotmail.com

F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
F2FS-fs (loop0): Found nat_bits in checkpoint
F2FS-fs (loop0): Try to recover 1th superblock, ret: 0
F2FS-fs (loop0): Mounted with checkpoint version = 48b305e5
======================================================
WARNING: possible circular locking dependency detected
6.4.0-syzkaller-12155-ga452483508d7 #0 Not tainted
------------------------------------------------------
syz-executor.0/5180 is trying to acquire lock:
ffff88803c1b90a0 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
ffff88803c1b90a0 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_getxattr+0xb8/0x1460 fs/f2fs/xattr.c:532

but task is already holding lock:
ffff88803c0196d8 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
ffff88803c0196d8 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_do_tmpfile+0x25/0x170 fs/f2fs/dir.c:838

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&fi->i_sem){+.+.}-{3:3}:
down_write+0x3a/0x50 kernel/locking/rwsem.c:1573
f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
f2fs_add_inline_entry+0x3a8/0x760 fs/f2fs/inline.c:644
f2fs_add_dentry+0xba/0x1e0 fs/f2fs/dir.c:784
f2fs_do_add_link+0x21e/0x340 fs/f2fs/dir.c:827
f2fs_add_link fs/f2fs/f2fs.h:3554 [inline]
f2fs_create+0x32c/0x530 fs/f2fs/namei.c:377
lookup_open fs/namei.c:3492 [inline]
open_last_lookups fs/namei.c:3560 [inline]
path_openat+0x13e7/0x3180 fs/namei.c:3790
do_filp_open+0x234/0x490 fs/namei.c:3820
do_sys_openat2+0x13e/0x1d0 fs/open.c:1407
do_sys_open fs/open.c:1422 [inline]
__do_sys_open fs/open.c:1430 [inline]
__se_sys_open fs/open.c:1426 [inline]
__x64_sys_open+0x225/0x270 fs/open.c:1426
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&fi->i_xattr_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+0x39ff/0x7f70 kernel/locking/lockdep.c:5144
lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5761
down_read+0x47/0x2f0 kernel/locking/rwsem.c:1520
f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
f2fs_getxattr+0xb8/0x1460 fs/f2fs/xattr.c:532
__f2fs_get_acl+0x52/0x8e0 fs/f2fs/acl.c:179
f2fs_acl_create fs/f2fs/acl.c:377 [inline]
f2fs_init_acl+0xd7/0x9a0 fs/f2fs/acl.c:420
f2fs_init_inode_metadata+0x824/0x1190 fs/f2fs/dir.c:558
f2fs_do_tmpfile+0x34/0x170 fs/f2fs/dir.c:839
__f2fs_tmpfile+0x1f9/0x380 fs/f2fs/namei.c:884
f2fs_ioc_start_atomic_write+0x4a3/0x9e0 fs/f2fs/file.c:2099
__f2fs_ioctl+0x1b5c/0xb770
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0xf8/0x170 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 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
---- ----
lock(&fi->i_sem);
lock(&fi->i_xattr_sem);
lock(&fi->i_sem);
rlock(&fi->i_xattr_sem);

*** DEADLOCK ***

5 locks held by syz-executor.0/5180:
#0: ffff888078fb2410 (sb_writers#16){.+.+}-{0:0}, at: mnt_want_write_file+0x61/0x200 fs/namespace.c:447
#1: ffff88803c018a28 (&sb->s_type->i_mutex_key#23){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:771 [inline]
#1: ffff88803c018a28 (&sb->s_type->i_mutex_key#23){+.+.}-{3:3}, at: f2fs_ioc_start_atomic_write+0x1b2/0x9e0 fs/f2fs/file.c:2060
#2: ffff88803c019008 (&fi->i_gc_rwsem[WRITE]){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
#2: ffff88803c019008 (&fi->i_gc_rwsem[WRITE]){+.+.}-{3:3}, at: f2fs_ioc_start_atomic_write+0x276/0x9e0 fs/f2fs/file.c:2074
#3: ffff88802b7e03b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
#3: ffff88802b7e03b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_lock_op fs/f2fs/f2fs.h:2151 [inline]
#3: ffff88802b7e03b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: __f2fs_tmpfile+0x1ce/0x380 fs/f2fs/namei.c:879
#4: ffff88803c0196d8 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
#4: ffff88803c0196d8 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_do_tmpfile+0x25/0x170 fs/f2fs/dir.c:838

stack backtrace:
CPU: 1 PID: 5180 Comm: syz-executor.0 Not tainted 6.4.0-syzkaller-12155-ga452483508d7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
check_noncircular+0x375/0x4a0 kernel/locking/lockdep.c:2195
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+0x39ff/0x7f70 kernel/locking/lockdep.c:5144
lock_acquire+0x1e3/0x520 kernel/locking/lockdep.c:5761
down_read+0x47/0x2f0 kernel/locking/rwsem.c:1520
f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
f2fs_getxattr+0xb8/0x1460 fs/f2fs/xattr.c:532
__f2fs_get_acl+0x52/0x8e0 fs/f2fs/acl.c:179
f2fs_acl_create fs/f2fs/acl.c:377 [inline]
f2fs_init_acl+0xd7/0x9a0 fs/f2fs/acl.c:420
f2fs_init_inode_metadata+0x824/0x1190 fs/f2fs/dir.c:558
f2fs_do_tmpfile+0x34/0x170 fs/f2fs/dir.c:839
__f2fs_tmpfile+0x1f9/0x380 fs/f2fs/namei.c:884
f2fs_ioc_start_atomic_write+0x4a3/0x9e0 fs/f2fs/file.c:2099
__f2fs_ioctl+0x1b5c/0xb770
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0xf8/0x170 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc9e168c389
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc9e2476168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fc9e17abf80 RCX: 00007fc9e168c389
RDX: 0000000000000000 RSI: 000000000000f501 RDI: 0000000000000005
RBP: 00007fc9e16d7493 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fffcc104f8f R14: 00007fc9e2476300 R15: 0000000000022000
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jul 10, 2023, 12:13:49 AM7/10/23
to ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: c192ac735768 MAINTAINERS 2: Electric Boogaloo
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1115adb0a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=9831e2c2660aae77
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=136809b4a80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1484e74ca80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a05cca457512/disk-c192ac73.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/87f55eba1b87/vmlinux-c192ac73.xz
kernel image: https://storage.googleapis.com/syzbot-assets/81e9815bafe0/bzImage-c192ac73.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/45865ba5a074/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e56005...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
6.4.0-syzkaller-12491-gc192ac735768 #0 Not tainted
------------------------------------------------------
syz-executor225/5016 is trying to acquire lock:
ffff888072747888 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
ffff888072747888 (&fi->i_xattr_sem){.+.+}-{3:3}, at: f2fs_getxattr+0xb96/0xfd0 fs/f2fs/xattr.c:532

but task is already holding lock:
ffff88807274b668 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
ffff88807274b668 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_do_tmpfile+0x24/0x1d0 fs/f2fs/dir.c:838

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&fi->i_sem){+.+.}-{3:3}:
down_write+0x92/0x200 kernel/locking/rwsem.c:1573
f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
f2fs_add_inline_entry+0x2c4/0x6c0 fs/f2fs/inline.c:644
f2fs_add_dentry+0xa6/0x240 fs/f2fs/dir.c:784
f2fs_do_add_link+0x183/0x270 fs/f2fs/dir.c:827
f2fs_add_link fs/f2fs/f2fs.h:3554 [inline]
f2fs_create+0x3c1/0x670 fs/f2fs/namei.c:377
lookup_open.isra.0+0x1050/0x1400 fs/namei.c:3492
open_last_lookups fs/namei.c:3560 [inline]
path_openat+0x969/0x2710 fs/namei.c:3790
do_filp_open+0x1ba/0x410 fs/namei.c:3820
do_sys_openat2+0x160/0x1c0 fs/open.c:1407
do_sys_open fs/open.c:1422 [inline]
__do_sys_openat fs/open.c:1438 [inline]
__se_sys_openat fs/open.c:1433 [inline]
__x64_sys_openat+0x143/0x1f0 fs/open.c:1433
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&fi->i_xattr_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+0x2e9d/0x5e20 kernel/locking/lockdep.c:5144
lock_acquire kernel/locking/lockdep.c:5761 [inline]
lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5726
down_read+0x9c/0x480 kernel/locking/rwsem.c:1520
f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
f2fs_getxattr+0xb96/0xfd0 fs/f2fs/xattr.c:532
__f2fs_get_acl+0x59/0x610 fs/f2fs/acl.c:179
f2fs_acl_create fs/f2fs/acl.c:377 [inline]
f2fs_init_acl+0x152/0xb40 fs/f2fs/acl.c:420
f2fs_init_inode_metadata+0x15d/0x1260 fs/f2fs/dir.c:558
f2fs_do_tmpfile+0x33/0x1d0 fs/f2fs/dir.c:839
__f2fs_tmpfile+0x1db/0x440 fs/f2fs/namei.c:884
f2fs_ioc_start_atomic_write+0xcf4/0x1330 fs/f2fs/file.c:2099
__f2fs_ioctl+0x317f/0xa5f0 fs/f2fs/file.c:4195
f2fs_ioctl+0x194/0x220 fs/f2fs/file.c:4287
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x19d/0x210 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/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
---- ----
lock(&fi->i_sem);
lock(&fi->i_xattr_sem);
lock(&fi->i_sem);
rlock(&fi->i_xattr_sem);

*** DEADLOCK ***

5 locks held by syz-executor225/5016:
#0: ffff88807a306410 (sb_writers#10){.+.+}-{0:0}, at: f2fs_ioc_start_atomic_write+0x1a7/0x1330 fs/f2fs/file.c:2056
#1: ffff888072749250 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:771 [inline]
#1: ffff888072749250 (&sb->s_type->i_mutex_key#15){+.+.}-{3:3}, at: f2fs_ioc_start_atomic_write+0x1e3/0x1330 fs/f2fs/file.c:2060
#2: ffff888072749830 (&fi->i_gc_rwsem[WRITE]){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
#2: ffff888072749830 (&fi->i_gc_rwsem[WRITE]){+.+.}-{3:3}, at: f2fs_ioc_start_atomic_write+0x2e6/0x1330 fs/f2fs/file.c:2074
#3: ffff88807ba403b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
#3: ffff88807ba403b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_lock_op fs/f2fs/f2fs.h:2151 [inline]
#3: ffff88807ba403b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: __f2fs_tmpfile+0x1ae/0x440 fs/f2fs/namei.c:879
#4: ffff88807274b668 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2133 [inline]
#4: ffff88807274b668 (&fi->i_sem){+.+.}-{3:3}, at: f2fs_do_tmpfile+0x24/0x1d0 fs/f2fs/dir.c:838

stack backtrace:
CPU: 1 PID: 5016 Comm: syz-executor225 Not tainted 6.4.0-syzkaller-12491-gc192ac735768 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
check_noncircular+0x2df/0x3b0 kernel/locking/lockdep.c:2195
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+0x2e9d/0x5e20 kernel/locking/lockdep.c:5144
lock_acquire kernel/locking/lockdep.c:5761 [inline]
lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5726
down_read+0x9c/0x480 kernel/locking/rwsem.c:1520
f2fs_down_read fs/f2fs/f2fs.h:2108 [inline]
f2fs_getxattr+0xb96/0xfd0 fs/f2fs/xattr.c:532
__f2fs_get_acl+0x59/0x610 fs/f2fs/acl.c:179
f2fs_acl_create fs/f2fs/acl.c:377 [inline]
f2fs_init_acl+0x152/0xb40 fs/f2fs/acl.c:420
f2fs_init_inode_metadata+0x15d/0x1260 fs/f2fs/dir.c:558
f2fs_do_tmpfile+0x33/0x1d0 fs/f2fs/dir.c:839
__f2fs_tmpfile+0x1db/0x440 fs/f2fs/namei.c:884
f2fs_ioc_start_atomic_write+0xcf4/0x1330 fs/f2fs/file.c:2099
__f2fs_ioctl+0x317f/0xa5f0 fs/f2fs/file.c:4195
f2fs_ioctl+0x194/0x220 fs/f2fs/file.c:4287
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x19d/0x210 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fe30f74c969
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc55cdfb78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe30f74c969
RDX: 0000000000000000 RSI: 000000000000f501 RDI: 0000000000000004
RBP: 00007fe30f70c200 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 00000000


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

Chao Yu

unread,
Jul 10, 2023, 10:48:58 AM7/10/23
to syzbot, syzkall...@googlegroups.com, Chao Yu
On 2023/7/10 12:13, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: c192ac735768 MAINTAINERS 2: Electric Boogaloo
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1115adb0a80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=9831e2c2660aae77
> dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=136809b4a80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1484e74ca80000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/a05cca457512/disk-c192ac73.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/87f55eba1b87/vmlinux-c192ac73.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/81e9815bafe0/bzImage-c192ac73.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/45865ba5a074/mount_0.gz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+e56005...@syzkaller.appspotmail.com

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git bugfix/syzbot

syzbot

unread,
Jul 10, 2023, 11:02:26 AM7/10/23
to ch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in f2fs_add_inline_entry

loop0: detected capacity change from 0 to 40427
F2FS-fs (loop0): Invalid log_blocksize (268), supports only 12
F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
F2FS-fs (loop0): Found nat_bits in checkpoint
F2FS-fs (loop0): Try to recover 1th superblock, ret: 0
F2FS-fs (loop0): Mounted with checkpoint version = 48b305e5
============================================
WARNING: possible recursive locking detected
6.5.0-rc1-syzkaller-00002-gf6f338f5680b #0 Not tainted
--------------------------------------------
syz-executor.0/5430 is trying to acquire lock:
ffff888065b99628 (&fi->i_sem){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2132 [inline]
ffff888065b99628 (&fi->i_sem){++++}-{3:3}, at: f2fs_add_inline_entry+0x2c4/0x6c0 fs/f2fs/inline.c:644

but task is already holding lock:
ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2107 [inline]
ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_add_dentry+0x3e/0x270 fs/f2fs/dir.c:784

other info that might help us debug this:
Possible unsafe locking scenario:

CPU0
----
lock(&fi->i_sem);
lock(&fi->i_sem);

*** DEADLOCK ***

May be due to missing lock nesting notation

4 locks held by syz-executor.0/5430:
#0: ffff88802de5a410 (sb_writers#14){.+.+}-{0:0}, at: open_last_lookups fs/namei.c:3549 [inline]
#0: ffff88802de5a410 (sb_writers#14){.+.+}-{0:0}, at: path_openat+0x26da/0x2710 fs/namei.c:3790
#1: ffff888065b95210 (&type->i_mutex_dir_key#8){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:771 [inline]
#1: ffff888065b95210 (&type->i_mutex_dir_key#8){+.+.}-{3:3}, at: open_last_lookups fs/namei.c:3557 [inline]
#1: ffff888065b95210 (&type->i_mutex_dir_key#8){+.+.}-{3:3}, at: path_openat+0x903/0x2710 fs/namei.c:3790
#2: ffff888074f303b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2107 [inline]
#2: ffff888074f303b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_lock_op fs/f2fs/f2fs.h:2150 [inline]
#2: ffff888074f303b0 (&sbi->cp_rwsem){.+.+}-{3:3}, at: f2fs_create+0x2e1/0x670 fs/f2fs/namei.c:376
#3: ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2107 [inline]
#3: ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_add_dentry+0x3e/0x270 fs/f2fs/dir.c:784

stack backtrace:
CPU: 1 PID: 5430 Comm: syz-executor.0 Not tainted 6.5.0-rc1-syzkaller-00002-gf6f338f5680b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/03/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
check_deadlock kernel/locking/lockdep.c:3070 [inline]
validate_chain kernel/locking/lockdep.c:3863 [inline]
__lock_acquire+0x2a33/0x5e20 kernel/locking/lockdep.c:5144
lock_acquire kernel/locking/lockdep.c:5761 [inline]
lock_acquire+0x1b1/0x520 kernel/locking/lockdep.c:5726
down_write+0x92/0x200 kernel/locking/rwsem.c:1573
f2fs_down_write fs/f2fs/f2fs.h:2132 [inline]
f2fs_add_inline_entry+0x2c4/0x6c0 fs/f2fs/inline.c:644
f2fs_add_dentry+0xac/0x270 fs/f2fs/dir.c:791
f2fs_do_add_link+0x183/0x270 fs/f2fs/dir.c:835
f2fs_add_link fs/f2fs/f2fs.h:3553 [inline]
f2fs_create+0x3c1/0x670 fs/f2fs/namei.c:377
lookup_open.isra.0+0x1050/0x1400 fs/namei.c:3492
open_last_lookups fs/namei.c:3560 [inline]
path_openat+0x969/0x2710 fs/namei.c:3790
do_filp_open+0x1ba/0x410 fs/namei.c:3820
do_sys_openat2+0x160/0x1c0 fs/open.c:1407
do_sys_open fs/open.c:1422 [inline]
__do_sys_openat fs/open.c:1438 [inline]
__se_sys_openat fs/open.c:1433 [inline]
__x64_sys_openat+0x143/0x1f0 fs/open.c:1433
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fb11928c389
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb11a039168 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fb1193abf80 RCX: 00007fb11928c389
RDX: 0000000000103a42 RSI: 0000000020000380 RDI: ffffffffffffff9c
RBP: 00007fb1192d7493 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd0f87853f R14: 00007fb11a039300 R15: 0000000000022000
</TASK>


Tested on:

commit: f6f338f5 f2fs: fix potential deadlock by reordering w/..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git bugfix/syzbot
console output: https://syzkaller.appspot.com/x/log.txt?x=1444efd2a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e75667d82b529c4f
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.

Chao Yu

unread,
Jul 10, 2023, 11:37:33 AM7/10/23
to syzbot, syzkall...@googlegroups.com, Chao Yu
On 2023/7/10 23:02, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> possible deadlock in f2fs_add_inline_entry
>
> loop0: detected capacity change from 0 to 40427
> F2FS-fs (loop0): Invalid log_blocksize (268), supports only 12
> F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
> F2FS-fs (loop0): Found nat_bits in checkpoint
> F2FS-fs (loop0): Try to recover 1th superblock, ret: 0
> F2FS-fs (loop0): Mounted with checkpoint version = 48b305e5
> ============================================
> WARNING: possible recursive locking detected
> 6.5.0-rc1-syzkaller-00002-gf6f338f5680b #0 Not tainted
> --------------------------------------------
> syz-executor.0/5430 is trying to acquire lock:
> ffff888065b99628 (&fi->i_sem){++++}-{3:3}, at: f2fs_down_write fs/f2fs/f2fs.h:2132 [inline]
> ffff888065b99628 (&fi->i_sem){++++}-{3:3}, at: f2fs_add_inline_entry+0x2c4/0x6c0 fs/f2fs/inline.c:644

https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/tree/fs/f2fs/inline.c?h=bugfix/syzbot#n644

int f2fs_add_inline_entry(struct inode *dir, const struct f2fs_filename *fname,
struct inode *inode, nid_t ino, umode_t mode)
{
...
if (inode) {
f2fs_down_write(&F2FS_I(inode)->i_sem);
page = f2fs_init_inode_metadata(inode, dir, fname, ipage);
if (IS_ERR(page)) {
err = PTR_ERR(page);
goto fail;
}
}
...
}

>
> but task is already holding lock:
> ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_down_read fs/f2fs/f2fs.h:2107 [inline]
> ffff888065b955e8 (&fi->i_sem){++++}-{3:3}, at: f2fs_add_dentry+0x3e/0x270 fs/f2fs/dir.c:784

https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/tree/fs/f2fs/dir.c?h=bugfix/syzbot#n784

int f2fs_add_dentry(struct inode *dir, const struct f2fs_filename *fname,
struct inode *inode, nid_t ino, umode_t mode)
{
int err = -EAGAIN;

f2fs_down_read(&F2FS_I(dir)->i_sem);

if (f2fs_has_inline_dentry(dir)) {
/*
* Should get i_sem to keep the lock order:
* i_sem -> inode_page lock used by f2fs_setxattr.
*/
err = f2fs_add_inline_entry(dir, fname, inode, ino, mode);
}
if (err == -EAGAIN)
err = f2fs_add_regular_entry(dir, fname, inode, ino, mode);

f2fs_up_read(&F2FS_I(dir)->i_sem);

f2fs_update_time(F2FS_I_SB(dir), REQ_TIME);
return err;
}

>
> other info that might help us debug this:
> Possible unsafe locking scenario:
>
> CPU0
> ----
> lock(&fi->i_sem);

f2fs_down_read(&F2FS_I(dir)->i_sem)

> lock(&fi->i_sem);

f2fs_down_write(&F2FS_I(inode)->i_sem);

So, is this false positive?

Thanks,

syzbot

unread,
Jul 14, 2023, 11:11:33 AM7/14/23
to ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 5eda1ad1aaffdfebdecf7a164e586060a210f74f
Author: Jaegeuk Kim <jae...@kernel.org>
Date: Wed Jun 28 08:00:56 2023 +0000

f2fs: fix deadlock in i_xattr_sem and inode page lock

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1177322aa80000
start commit: 3f01e9fed845 Merge tag 'linux-watchdog-6.5-rc2' of git://w..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=1377322aa80000
console output: https://syzkaller.appspot.com/x/log.txt?x=1577322aa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=29fd3392a08741ef
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1336f364a80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=130a365aa80000

Reported-by: syzbot+e56005...@syzkaller.appspotmail.com
Fixes: 5eda1ad1aaff ("f2fs: fix deadlock in i_xattr_sem and inode page lock")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Hillf Danton

unread,
Jul 14, 2023, 9:26:17 PM7/14/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Sun, 09 Jul 2023 21:13:48 -0700
> HEAD commit: c192ac735768 MAINTAINERS 2: Electric Boogaloo
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1484e74ca80000

Force the locking order

lock(&fi->i_sem);
lock(&fi->i_xattr_sem);

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git c192ac735768

--- x/fs/f2fs/dir.c
+++ y/fs/f2fs/dir.c
@@ -776,6 +776,8 @@ int f2fs_add_dentry(struct inode *dir, c
int err = -EAGAIN;

if (f2fs_has_inline_dentry(dir)) {
+ if (inode)
+ f2fs_down_write(&F2FS_I(inode)->i_sem);
/*
* Should get i_xattr_sem to keep the lock order:
* i_xattr_sem -> inode_page lock used by f2fs_setxattr.
@@ -783,6 +785,8 @@ int f2fs_add_dentry(struct inode *dir, c
f2fs_down_read(&F2FS_I(dir)->i_xattr_sem);
err = f2fs_add_inline_entry(dir, fname, inode, ino, mode);
f2fs_up_read(&F2FS_I(dir)->i_xattr_sem);
+ if (inode)
+ f2fs_up_write(&F2FS_I(inode)->i_sem);
}
if (err == -EAGAIN)
err = f2fs_add_regular_entry(dir, fname, inode, ino, mode);
--- x/fs/f2fs/inline.c
+++ y/fs/f2fs/inline.c
@@ -641,11 +641,10 @@ int f2fs_add_inline_entry(struct inode *
}

if (inode) {
- f2fs_down_write(&F2FS_I(inode)->i_sem);
page = f2fs_init_inode_metadata(inode, dir, fname, ipage);
if (IS_ERR(page)) {
err = PTR_ERR(page);
- goto fail;
+ goto out;
}
}

@@ -668,9 +667,6 @@ int f2fs_add_inline_entry(struct inode *
}

f2fs_update_parent_metadata(dir, inode, 0);
-fail:
- if (inode)
- f2fs_up_write(&F2FS_I(inode)->i_sem);
out:
f2fs_put_page(ipage, 1);
return err;
--

syzbot

unread,
Jul 14, 2023, 9:48:28 PM7/14/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e56005...@syzkaller.appspotmail.com

Tested on:

commit: c192ac73 MAINTAINERS 2: Electric Boogaloo
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=10875224a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=268de7231d485f5b
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=130c008aa80000

Note: testing is done by a robot and is best-effort only.

Jaegeuk Kim

unread,
Aug 18, 2023, 3:51:34 PM8/18/23
to syzbot, ch...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test: github.com/jaegeuk/f2fs/tree/g-dev-test g-dev-test

syzbot

unread,
Aug 18, 2023, 3:51:35 PM8/18/23
to jae...@kernel.org, ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
> #syz test: github.com/jaegeuk/f2fs/tree/g-dev-test g-dev-test

"github.com/jaegeuk/f2fs/tree/g-dev-test" does not look like a valid git repo address.

Jaegeuk Kim

unread,
Aug 18, 2023, 4:15:05 PM8/18/23
to syzbot, ch...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test: https://github.com/jaegeuk/f2fs.git g-dev-test

syzbot

unread,
Aug 18, 2023, 5:02:36 PM8/18/23
to ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e56005...@syzkaller.appspotmail.com

Tested on:

commit: 261546ae f2fs: avoid false alarm of circular locking
git tree: https://github.com/jaegeuk/f2fs.git g-dev-test
console output: https://syzkaller.appspot.com/x/log.txt?x=16c22b3ba80000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d0f369ef5fb88c9
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.

Jaegeuk Kim

unread,
Aug 18, 2023, 5:15:04 PM8/18/23
to syzbot, ch...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test: https://github.com/jaegeuk/f2fs.git g-dev-test

On 07/06, syzbot wrote:

syzbot

unread,
Aug 18, 2023, 5:49:32 PM8/18/23
to ch...@kernel.org, jae...@kernel.org, linux-f2...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e56005...@syzkaller.appspotmail.com

Tested on:

commit: 47e4a92b f2fs: avoid false alarm of circular locking
console output: https://syzkaller.appspot.com/x/log.txt?x=16b569efa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d0f369ef5fb88c9
dashboard link: https://syzkaller.appspot.com/bug?extid=e5600587fa9cbf8e3826
Reply all
Reply to author
Forward
0 new messages