[v5.15] possible deadlock in blocking_notifier_call_chain

2 views
Skip to first unread message

syzbot

unread,
Mar 10, 2023, 3:18:38 AM3/10/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d9b4a0c83a2d Linux 5.15.98
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12b17deac80000
kernel config: https://syzkaller.appspot.com/x/.config?x=b57cfa804330c3b7
dashboard link: https://syzkaller.appspot.com/bug?extid=b8a9f7d37662f670788e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8088989394e3/disk-d9b4a0c8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2651d6753959/vmlinux-d9b4a0c8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f3fa3f994f9a/Image-d9b4a0c8.gz.xz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.98-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/12583 is trying to acquire lock:
ffff800015095030 ((crypto_chain).rwsem){++++}-{3:3}, at: blocking_notifier_call_chain+0x60/0x198 kernel/notifier.c:317

but task is already holding lock:
ffff0000d5f831f8 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
ffff0000d5f831f8 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:302

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}:
down_write+0x110/0x260 kernel/locking/rwsem.c:1533
inode_lock include/linux/fs.h:787 [inline]
hugetlbfs_file_mmap+0x298/0x4c0 fs/hugetlbfs/inode.c:175
call_mmap include/linux/fs.h:2106 [inline]
mmap_region+0xcb4/0x12f0 mm/mmap.c:1791
do_mmap+0x6c0/0xcec mm/mmap.c:1575
vm_mmap_pgoff+0x1a4/0x2b4 mm/util.c:551
ksys_mmap_pgoff+0x4c8/0x668 mm/mmap.c:1624
__do_sys_mmap arch/arm64/kernel/sys.c:28 [inline]
__se_sys_mmap arch/arm64/kernel/sys.c:21 [inline]
__arm64_sys_mmap+0xf8/0x110 arch/arm64/kernel/sys.c:21
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

-> #2 (&mm->mmap_lock){++++}-{3:3}:
down_write+0x110/0x260 kernel/locking/rwsem.c:1533
mmap_write_lock include/linux/mmap_lock.h:71 [inline]
mpol_rebind_mm+0x40/0x298 mm/mempolicy.c:381
cpuset_attach+0x370/0x4c8 kernel/cgroup/cpuset.c:2285
cgroup_migrate_execute+0x6d8/0xd8c kernel/cgroup/cgroup.c:2559
cgroup_migrate+0x18c/0x1a4 kernel/cgroup/cgroup.c:2821
cgroup_attach_task+0x4d0/0xa3c kernel/cgroup/cgroup.c:2854
__cgroup1_procs_write+0x308/0x41c kernel/cgroup/cgroup-v1.c:528
cgroup1_procs_write+0x38/0x4c kernel/cgroup/cgroup-v1.c:541
cgroup_file_write+0x258/0x56c kernel/cgroup/cgroup.c:3932
kernfs_fop_write_iter+0x334/0x48c fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2101 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0x87c/0xb3c fs/read_write.c:594
ksys_write+0x15c/0x26c fs/read_write.c:647
__do_sys_write fs/read_write.c:659 [inline]
__se_sys_write fs/read_write.c:656 [inline]
__arm64_sys_write+0x7c/0x90 fs/read_write.c:656
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

-> #1 (&cpuset_rwsem){++++}-{0:0}:
percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
cpuset_read_lock+0xe4/0x348 kernel/cgroup/cpuset.c:356
__sched_setscheduler+0x4b8/0x1680 kernel/sched/core.c:7406
_sched_setscheduler kernel/sched/core.c:7583 [inline]
sched_setscheduler_nocheck+0x14c/0x258 kernel/sched/core.c:7630
__kthread_create_on_node+0x2f8/0x3d0 kernel/kthread.c:413
kthread_create_on_node+0xf0/0x140 kernel/kthread.c:453
cryptomgr_schedule_test crypto/algboss.c:219 [inline]
cryptomgr_notify+0x110/0xb48 crypto/algboss.c:240
notifier_call_chain kernel/notifier.c:83 [inline]
blocking_notifier_call_chain+0xf0/0x198 kernel/notifier.c:318
crypto_probing_notify+0x34/0x94 crypto/api.c:251
crypto_wait_for_test crypto/algapi.c:396 [inline]
crypto_register_alg+0x24c/0x3a8 crypto/algapi.c:429
crypto_register_kpp+0x70/0xa8 crypto/kpp.c:104
dh_init+0x1c/0x28 crypto/dh.c:265
do_one_initcall+0x2c4/0xc28 init/main.c:1306
do_initcall_level+0x154/0x214 init/main.c:1379
do_initcalls+0x58/0xac init/main.c:1395
do_basic_setup+0x8c/0xa0 init/main.c:1414
kernel_init_freeable+0x470/0x650 init/main.c:1619
kernel_init+0x24/0x294 init/main.c:1510
ret_from_fork+0x10/0x20 <unknown>:870

-> #0 ((crypto_chain).rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x2b8/0x894 kernel/locking/lockdep.c:5622
down_read+0xbc/0x11c kernel/locking/rwsem.c:1480
blocking_notifier_call_chain+0x60/0x198 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x290/0x63c crypto/api.c:281
crypto_has_alg+0x38/0x168 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x60c/0x798 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x188/0x200 security/security.c:1370
__vfs_setxattr_locked+0xb4/0x218 fs/xattr.c:268
vfs_setxattr+0x1a8/0x344 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x250/0x2b4 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr fs/xattr.c:656 [inline]
__arm64_sys_fsetxattr+0x1a8/0x224 fs/xattr.c:656
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

other info that might help us debug this:

Chain exists of:
(crypto_chain).rwsem --> &mm->mmap_lock --> &sb->s_type->i_mutex_key#21

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sb->s_type->i_mutex_key#21);
lock(&mm->mmap_lock);
lock(&sb->s_type->i_mutex_key#21);
lock((crypto_chain).rwsem);

*** DEADLOCK ***

2 locks held by syz-executor.4/12583:
#0: ffff0000c2d3c460 (sb_writers#14){.+.+}-{0:0}, at: mnt_want_write_file+0x64/0x1e8 fs/namespace.c:421
#1: ffff0000d5f831f8 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff0000d5f831f8 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:302

stack backtrace:
CPU: 0 PID: 12583 Comm: syz-executor.4 Not tainted 5.15.98-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x2b8/0x894 kernel/locking/lockdep.c:5622
down_read+0xbc/0x11c kernel/locking/rwsem.c:1480
blocking_notifier_call_chain+0x60/0x198 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x290/0x63c crypto/api.c:281
crypto_has_alg+0x38/0x168 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x60c/0x798 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x188/0x200 security/security.c:1370
__vfs_setxattr_locked+0xb4/0x218 fs/xattr.c:268
vfs_setxattr+0x1a8/0x344 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x250/0x2b4 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr fs/xattr.c:656 [inline]
__arm64_sys_fsetxattr+0x1a8/0x224 fs/xattr.c:656
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584


---
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.

syzbot

unread,
Mar 11, 2023, 8:44:39 AM3/11/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: abddfcf701a5 Linux 5.15.99
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1248305cc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e8038112e99511e7
dashboard link: https://syzkaller.appspot.com/bug?extid=b8a9f7d37662f670788e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16deb7e4c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5d41fec63ff8/disk-abddfcf7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/69db433dc01f/vmlinux-abddfcf7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a00e1270bd95/bzImage-abddfcf7.xz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.99-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/5599 is trying to acquire lock:
ffffffff8cebdd50 ((crypto_chain).rwsem){++++}-{3:3}, at: blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317

but task is already holding lock:
ffff88805bbce258 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
ffff88805bbce258 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 fs/xattr.c:302

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_write+0x97/0x170 kernel/locking/rwsem.c:1541
inode_lock include/linux/fs.h:787 [inline]
hugetlbfs_file_mmap+0x2bc/0x580 fs/hugetlbfs/inode.c:175
call_mmap include/linux/fs.h:2106 [inline]
mmap_region+0x10e7/0x1670 mm/mmap.c:1791
do_mmap+0x78d/0xe00 mm/mmap.c:1575
vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551
ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1624
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #2 (&mm->mmap_lock#2){++++}-{3:3}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_write+0x97/0x170 kernel/locking/rwsem.c:1541
mmap_write_lock include/linux/mmap_lock.h:71 [inline]
mpol_rebind_mm+0x34/0x2b0 mm/mempolicy.c:381
cpuset_attach+0x393/0x540 kernel/cgroup/cpuset.c:2285
cgroup_migrate_execute+0x7fb/0x10e0 kernel/cgroup/cgroup.c:2559
cgroup_attach_task+0x587/0x910 kernel/cgroup/cgroup.c:2854
__cgroup1_procs_write+0x2ec/0x460 kernel/cgroup/cgroup-v1.c:528
cgroup_file_write+0x2ac/0x670 kernel/cgroup/cgroup.c:3932
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2101 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #1 (&cpuset_rwsem){++++}-{0:0}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
cpuset_read_lock+0x40/0x150 kernel/cgroup/cpuset.c:356
__sched_setscheduler+0x626/0x1df0 kernel/sched/core.c:7406
_sched_setscheduler kernel/sched/core.c:7583 [inline]
sched_setscheduler_nocheck+0x187/0x2d0 kernel/sched/core.c:7630
__kthread_create_on_node+0x31b/0x3f0 kernel/kthread.c:413
kthread_create_on_node+0xda/0x120 kernel/kthread.c:453
cryptomgr_schedule_test crypto/algboss.c:219 [inline]
cryptomgr_notify+0x125/0xc70 crypto/algboss.c:240
notifier_call_chain kernel/notifier.c:83 [inline]
blocking_notifier_call_chain+0x104/0x1b0 kernel/notifier.c:318
crypto_probing_notify+0x21/0x70 crypto/api.c:251
crypto_wait_for_test+0x3e/0xd0 crypto/algapi.c:396
crypto_register_alg+0x25b/0x330 crypto/algapi.c:429
do_one_initcall+0x293/0x930 init/main.c:1306
do_initcall_level+0x157/0x207 init/main.c:1379
do_initcalls+0x49/0x86 init/main.c:1395
kernel_init_freeable+0x43c/0x5c5 init/main.c:1619
kernel_init+0x19/0x290 init/main.c:1510
ret_from_fork+0x1f/0x30 <unknown>:298

-> #0 ((crypto_chain).rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x4e6/0x710 crypto/api.c:281
crypto_has_alg+0x22/0x110 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x836/0xa10 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x1b0/0x230 security/security.c:1370
__vfs_setxattr_locked+0xa6/0x240 fs/xattr.c:268
vfs_setxattr+0x21d/0x420 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x27e/0x2e0 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr+0x194/0x210 fs/xattr.c:656
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

other info that might help us debug this:

Chain exists of:
(crypto_chain).rwsem --> &mm->mmap_lock#2 --> &sb->s_type->i_mutex_key#21

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sb->s_type->i_mutex_key#21);
lock(&mm->mmap_lock#2);
lock(&sb->s_type->i_mutex_key#21);
lock((crypto_chain).rwsem);

*** DEADLOCK ***

2 locks held by syz-executor.4/5599:
#0: ffff8881417d2460 (sb_writers#13){.+.+}-{0:0}, at: mnt_want_write_file+0x5a/0x1f0 fs/namespace.c:421
#1: ffff88805bbce258 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff88805bbce258 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 fs/xattr.c:302

stack backtrace:
CPU: 0 PID: 5599 Comm: syz-executor.4 Not tainted 5.15.99-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x4e6/0x710 crypto/api.c:281
crypto_has_alg+0x22/0x110 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x836/0xa10 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x1b0/0x230 security/security.c:1370
__vfs_setxattr_locked+0xa6/0x240 fs/xattr.c:268
vfs_setxattr+0x21d/0x420 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x27e/0x2e0 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr+0x194/0x210 fs/xattr.c:656
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fab044390f9
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:00007fab037ab168 EFLAGS: 00000246 ORIG_RAX: 00000000000000be
RAX: ffffffffffffffda RBX: 00007fab04558f80 RCX: 00007fab044390f9
RDX: 00000000200000c0 RSI: 0000000020000080 RDI: 0000000000000008
RBP: 00007fab04494ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000000a R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffeffd0315f R14: 00007fab037ab300 R15: 0000000000022000
</TASK>

syzbot

unread,
Mar 11, 2023, 9:49:39 PM3/11/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: d214f240b0f6 Linux 5.15.100
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17b505b8c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c5c5a36ceb954515
dashboard link: https://syzkaller.appspot.com/bug?extid=b8a9f7d37662f670788e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=126d66eac80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10fd2d42c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/4e12037285d4/disk-d214f240.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/929d982226d5/vmlinux-d214f240.xz
kernel image: https://storage.googleapis.com/syzbot-assets/59140c032c99/bzImage-d214f240.xz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.100-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor104/3586 is trying to acquire lock:
ffffffff8cebddb0 ((crypto_chain).rwsem){++++}-{3:3}, at: blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317

but task is already holding lock:
ffff888016cb91b8 (&sb->s_type->i_mutex_key#19){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
ffff888016cb91b8 (&sb->s_type->i_mutex_key#19){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 fs/xattr.c:302

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&sb->s_type->i_mutex_key#19){+.+.}-{3:3}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_write+0x97/0x170 kernel/locking/rwsem.c:1541
inode_lock include/linux/fs.h:787 [inline]
hugetlbfs_file_mmap+0x2bc/0x580 fs/hugetlbfs/inode.c:175
call_mmap include/linux/fs.h:2106 [inline]
mmap_region+0x10e7/0x1670 mm/mmap.c:1791
do_mmap+0x78d/0xe00 mm/mmap.c:1575
vm_mmap_pgoff+0x1ca/0x2d0 mm/util.c:551
ksys_mmap_pgoff+0x559/0x780 mm/mmap.c:1624
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #2 (&mm->mmap_lock#2){++++}-{3:3}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_write+0x97/0x170 kernel/locking/rwsem.c:1541
mmap_write_lock include/linux/mmap_lock.h:71 [inline]
mpol_rebind_mm+0x34/0x2b0 mm/mempolicy.c:381
cpuset_attach+0x393/0x540 kernel/cgroup/cpuset.c:2285
cgroup_migrate_execute+0x7fb/0x10e0 kernel/cgroup/cgroup.c:2559
cgroup_attach_task+0x587/0x910 kernel/cgroup/cgroup.c:2854
__cgroup1_procs_write+0x2ec/0x460 kernel/cgroup/cgroup-v1.c:528
cgroup_file_write+0x2ac/0x670 kernel/cgroup/cgroup.c:3932
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2101 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #1 (&cpuset_rwsem){++++}-{0:0}:
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
cpuset_read_lock+0x40/0x150 kernel/cgroup/cpuset.c:356
__sched_setscheduler+0x626/0x1df0 kernel/sched/core.c:7406
_sched_setscheduler kernel/sched/core.c:7583 [inline]
sched_setscheduler_nocheck+0x187/0x2d0 kernel/sched/core.c:7630
__kthread_create_on_node+0x31b/0x3f0 kernel/kthread.c:413
kthread_create_on_node+0xda/0x120 kernel/kthread.c:453
cryptomgr_schedule_test crypto/algboss.c:219 [inline]
cryptomgr_notify+0x125/0xc70 crypto/algboss.c:240
notifier_call_chain kernel/notifier.c:83 [inline]
blocking_notifier_call_chain+0x104/0x1b0 kernel/notifier.c:318
crypto_probing_notify+0x21/0x70 crypto/api.c:251
crypto_wait_for_test+0x3e/0xd0 crypto/algapi.c:396
crypto_register_alg+0x25b/0x330 crypto/algapi.c:429
do_one_initcall+0x293/0x930 init/main.c:1306
do_initcall_level+0x157/0x207 init/main.c:1379
do_initcalls+0x49/0x86 init/main.c:1395
kernel_init_freeable+0x43c/0x5c5 init/main.c:1619
kernel_init+0x19/0x290 init/main.c:1510
ret_from_fork+0x1f/0x30 <unknown>:298

-> #0 ((crypto_chain).rwsem){++++}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x4e6/0x710 crypto/api.c:281
crypto_has_alg+0x22/0x110 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x836/0xa10 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x1b0/0x230 security/security.c:1370
__vfs_setxattr_locked+0xa6/0x240 fs/xattr.c:268
vfs_setxattr+0x21d/0x420 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x27e/0x2e0 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr+0x194/0x210 fs/xattr.c:656
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

other info that might help us debug this:

Chain exists of:
(crypto_chain).rwsem --> &mm->mmap_lock#2 --> &sb->s_type->i_mutex_key#19

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&sb->s_type->i_mutex_key#19);
lock(&mm->mmap_lock#2);
lock(&sb->s_type->i_mutex_key#19);
lock((crypto_chain).rwsem);

*** DEADLOCK ***

2 locks held by syz-executor104/3586:
#0: ffff888016cb4460 (sb_writers#11){.+.+}-{0:0}, at: mnt_want_write_file+0x5a/0x1f0 fs/namespace.c:421
#1: ffff888016cb91b8 (&sb->s_type->i_mutex_key#19){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff888016cb91b8 (&sb->s_type->i_mutex_key#19){+.+.}-{3:3}, at: vfs_setxattr+0x1dd/0x420 fs/xattr.c:302

stack backtrace:
CPU: 0 PID: 3586 Comm: syz-executor104 Not tainted 5.15.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
lock_acquire+0x1ff/0x570 kernel/locking/lockdep.c:5622
down_read+0x3b/0x50 kernel/locking/rwsem.c:1488
blocking_notifier_call_chain+0x5e/0x1b0 kernel/notifier.c:317
crypto_probing_notify crypto/api.c:251 [inline]
crypto_alg_mod_lookup+0x4e6/0x710 crypto/api.c:281
crypto_has_alg+0x22/0x110 crypto/api.c:581
validate_hash_algo security/integrity/ima/ima_appraise.c:623 [inline]
ima_inode_setxattr+0x836/0xa10 security/integrity/ima/ima_appraise.c:655
security_inode_setxattr+0x1b0/0x230 security/security.c:1370
__vfs_setxattr_locked+0xa6/0x240 fs/xattr.c:268
vfs_setxattr+0x21d/0x420 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x27e/0x2e0 fs/xattr.c:611
__do_sys_fsetxattr fs/xattr.c:667 [inline]
__se_sys_fsetxattr+0x194/0x210 fs/xattr.c:656
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f5a71688e29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 15 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:00007ffcb4fef6e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000be
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f5a71688e29
RDX: 00000000200000c0 RSI: 0000000020000080 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 00007ffcb4fef710
R10: 000000000000000a R11: 0000000000000246 R12: 00007ffcb4fef70c
R13: 00007ffcb4fef720 R14: 00007ffcb4fef760 R15: 0000000000000000
</TASK>

syzbot

unread,
Sep 25, 2023, 2:11:15 PM9/25/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit 1a7243ca4074beed97b68d7235a6e34862fc2cd6
git tree: upstream
Author: Sebastian Andrzej Siewior <big...@linutronix.de>
Date: Tue Nov 10 11:38:47 2020 +0000

kthread: Move prio/affinite change into the newly created thread

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13e82f0e680000
kernel config: https://syzkaller.appspot.com/x/.config?x=f5592cc4916e1c2f
dashboard link: https://syzkaller.appspot.com/bug?extid=b8a9f7d37662f670788e
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=154381dec80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1659eb89c80000


Please keep in mind that other backports might be required as well.

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages