syzbot


possible deadlock in get_page_from_freelist

Status: upstream: reported on 2024/04/04 02:53
Reported-by: syzbot+3af261d4bddef218b69c@syzkaller.appspotmail.com
First crash: 77d, last: 77d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in get_page_from_freelist bpf 11 3d11h 66d 0/27 upstream: reported on 2024/04/15 02:28

Sample crash report:
------------[ cut here ]------------
======================================================
WARNING: possible circular locking dependency detected
5.15.153-syzkaller #0 Not tainted
------------------------------------------------------
udevd/7989 is trying to acquire lock:
ffffffff8c7fbf78 ((console_sem).lock){-.-.}-{2:2}, at: down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138

but task is already holding lock:
ffff8880b9a35ca8 (lock){-.-.}-{2:2}, at: local_lock_acquire+0x7/0x130 include/linux/local_lock_internal.h:28

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (lock){-.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       local_lock_acquire+0x23/0x130 include/linux/local_lock_internal.h:29
       rmqueue_pcplist mm/page_alloc.c:3652 [inline]
       rmqueue mm/page_alloc.c:3690 [inline]
       get_page_from_freelist+0x27cc/0x33c0 mm/page_alloc.c:4156
       __alloc_pages+0x272/0x700 mm/page_alloc.c:5421
       alloc_slab_page mm/slub.c:1775 [inline]
       allocate_slab mm/slub.c:1912 [inline]
       new_slab+0xbb/0x4b0 mm/slub.c:1975
       ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
       __slab_alloc mm/slub.c:3095 [inline]
       slab_alloc_node mm/slub.c:3186 [inline]
       __kmalloc_node+0x1fa/0x390 mm/slub.c:4451
       kmalloc_node include/linux/slab.h:614 [inline]
       bpf_map_kmalloc_node+0xdb/0x160 kernel/bpf/syscall.c:430
       lpm_trie_node_alloc kernel/bpf/lpm_trie.c:290 [inline]
       trie_update_elem+0x1cb/0xc00 kernel/bpf/lpm_trie.c:332
       bpf_map_update_value+0x5d7/0x6c0 kernel/bpf/syscall.c:221
       map_update_elem+0x6a0/0x7c0 kernel/bpf/syscall.c:1185
       __sys_bpf+0x2fd/0x670 kernel/bpf/syscall.c:4639
       __do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
       __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
       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

-> #3 (&trie->lock){..-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
       trie_delete_elem+0x90/0x690 kernel/bpf/lpm_trie.c:450
       0xffffffffa002a3e5
       bpf_dispatcher_nop_func include/linux/bpf.h:785 [inline]
       __bpf_prog_run include/linux/filter.h:628 [inline]
       bpf_prog_run include/linux/filter.h:635 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:1880 [inline]
       bpf_trace_run3+0x1d1/0x380 kernel/trace/bpf_trace.c:1918
       __traceiter_sched_switch+0x7d/0xb0 include/trace/events/sched.h:220
       trace_sched_switch include/trace/events/sched.h:220 [inline]
       __schedule+0x1e8d/0x45b0 kernel/sched/core.c:6373
       preempt_schedule_irq+0xf7/0x1c0 kernel/sched/core.c:6780
       irqentry_exit+0x53/0x80 kernel/entry/common.c:426
       asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:638
       call_rcu+0x7aa/0xa70 kernel/rcu/tree.c:3088
       release_probes kernel/tracepoint.c:164 [inline]
       tracepoint_add_func+0x618/0x9d0 kernel/tracepoint.c:386
       tracepoint_probe_register_prio_may_exist+0x11e/0x190 kernel/tracepoint.c:482
       bpf_raw_tracepoint_open+0x65a/0x750 kernel/bpf/syscall.c:3113
       __sys_bpf+0x468/0x670 kernel/bpf/syscall.c:4693
       __do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
       __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
       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 (&rq->__lock){-.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       _raw_spin_lock_nested+0x2d/0x40 kernel/locking/spinlock.c:368
       raw_spin_rq_lock_nested+0x26/0x140 kernel/sched/core.c:475
       raw_spin_rq_lock kernel/sched/sched.h:1326 [inline]
       rq_lock kernel/sched/sched.h:1621 [inline]
       task_fork_fair+0x5d/0x350 kernel/sched/fair.c:11480
       sched_cgroup_fork+0x2d3/0x330 kernel/sched/core.c:4466
       copy_process+0x224a/0x3ef0 kernel/fork.c:2320
       kernel_clone+0x210/0x960 kernel/fork.c:2604
       kernel_thread+0x168/0x1e0 kernel/fork.c:2656
       rest_init+0x21/0x330 init/main.c:704
       start_kernel+0x48c/0x535 init/main.c:1138
       secondary_startup_64_no_verify+0xb1/0xbb

-> #1 (&p->pi_lock){-.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
       try_to_wake_up+0xae/0x1300 kernel/sched/core.c:4030
       up+0x6e/0x90 kernel/locking/semaphore.c:190
       __up_console_sem+0x11a/0x1e0 kernel/printk/printk.c:256
       console_unlock+0x1145/0x12b0 kernel/printk/printk.c:2754
       vprintk_emit+0xbf/0x150 kernel/printk/printk.c:2268
       dev_vprintk_emit+0x2aa/0x323 drivers/base/core.c:4595
       dev_printk_emit+0xd9/0x118 drivers/base/core.c:4606
       _dev_notice+0x11e/0x165 drivers/base/core.c:4663
       usb_parse_endpoint drivers/usb/core/config.c:411 [inline]
       usb_parse_interface drivers/usb/core/config.c:582 [inline]
       usb_parse_configuration drivers/usb/core/config.c:795 [inline]
       usb_get_configuration+0x2f72/0x4d60 drivers/usb/core/config.c:944
       usb_enumerate_device drivers/usb/core/hub.c:2416 [inline]
       usb_new_device+0x146/0x18e0 drivers/usb/core/hub.c:2554
       hub_port_connect drivers/usb/core/hub.c:5445 [inline]
       hub_port_connect_change drivers/usb/core/hub.c:5585 [inline]
       port_event drivers/usb/core/hub.c:5731 [inline]
       hub_event+0x2cdf/0x54c0 drivers/usb/core/hub.c:5813
       process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
       worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
       kthread+0x3f6/0x4f0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #0 ((console_sem).lock){-.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
       down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138
       __down_trylock_console_sem+0x105/0x250 kernel/printk/printk.c:239
       console_trylock kernel/printk/printk.c:2569 [inline]
       console_trylock_spinning+0x8a/0x3f0 kernel/printk/printk.c:1867
       vprintk_emit+0xa6/0x150 kernel/printk/printk.c:2267
       _printk+0xd1/0x111 kernel/printk/printk.c:2293
       report_bug+0x1e5/0x2e0 lib/bug.c:195
       handle_bug+0x3d/0x70 arch/x86/kernel/traps.c:239
       exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:259
       asm_exc_invalid_op+0x16/0x20 arch/x86/include/asm/idtentry.h:566
       __local_bh_enable_ip+0x1b3/0x1f0
       __sock_map_delete net/core/sock_map.c:426 [inline]
       sock_map_delete_elem+0xcb/0x130 net/core/sock_map.c:448
       bpf_prog_2c29ac5cdc6b1842+0x3a/0x154
       bpf_dispatcher_nop_func include/linux/bpf.h:785 [inline]
       __bpf_prog_run include/linux/filter.h:628 [inline]
       bpf_prog_run include/linux/filter.h:635 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:1880 [inline]
       bpf_trace_run1+0x168/0x2f0 kernel/trace/bpf_trace.c:1916
       __bpf_trace_mm_page_free_batched+0x41/0x60 include/trace/events/kmem.h:182
       trace_mm_page_free_batched include/trace/events/kmem.h:182 [inline]
       free_unref_page_list+0x79b/0x8e0 mm/page_alloc.c:3465
       release_pages+0x1bb9/0x1f40 mm/swap.c:963
       __pagevec_release+0x80/0xf0 mm/swap.c:983
       pagevec_release include/linux/pagevec.h:81 [inline]
       shmem_undo_range+0x67a/0x1b50 mm/shmem.c:964
       shmem_truncate_range mm/shmem.c:1063 [inline]
       shmem_evict_inode+0x21b/0xa00 mm/shmem.c:1145
       evict+0x2a4/0x620 fs/inode.c:587
       __dentry_kill+0x436/0x650 fs/dcache.c:582
       dentry_kill+0xbb/0x290
       dput+0xd8/0x1a0 fs/dcache.c:889
       do_renameat2+0xe1c/0x1700 fs/namei.c:4987
       __do_sys_rename fs/namei.c:5031 [inline]
       __se_sys_rename fs/namei.c:5029 [inline]
       __x64_sys_rename+0x82/0x90 fs/namei.c:5029
       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:
  (console_sem).lock --> &trie->lock --> lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(lock);
                               lock(&trie->lock);
                               lock(lock);
  lock((console_sem).lock);

 *** DEADLOCK ***

4 locks held by udevd/7989:
 #0: ffff88807ec14460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x3b/0x80 fs/namespace.c:377
 #1: ffff88807e369b58 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: do_renameat2+0x67e/0x1700 fs/namei.c:4924
 #2: ffff8880b9a35ca8 (lock){-.-.}-{2:2}, at: local_lock_acquire+0x7/0x130 include/linux/local_lock_internal.h:28
 #3: ffffffff8c91f720 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire+0x5/0x30 include/linux/rcupdate.h:311

stack backtrace:
CPU: 0 PID: 7989 Comm: udevd Not tainted 5.15.153-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
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+0x1649/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
 down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138
 __down_trylock_console_sem+0x105/0x250 kernel/printk/printk.c:239
 console_trylock kernel/printk/printk.c:2569 [inline]
 console_trylock_spinning+0x8a/0x3f0 kernel/printk/printk.c:1867
 vprintk_emit+0xa6/0x150 kernel/printk/printk.c:2267
 _printk+0xd1/0x111 kernel/printk/printk.c:2293
 report_bug+0x1e5/0x2e0 lib/bug.c:195
 handle_bug+0x3d/0x70 arch/x86/kernel/traps.c:239
 exc_invalid_op+0x16/0x40 arch/x86/kernel/traps.c:259
 asm_exc_invalid_op+0x16/0x20 arch/x86/include/asm/idtentry.h:566
RIP: 0010:__local_bh_enable_ip+0x1b3/0x1f0 kernel/softirq.c:363
Code: 04 25 28 00 00 00 48 3b 44 24 60 75 4a 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b e9 d0 fe ff ff e8 3f 00 00 00 eb a2 <0f> 0b e9 02 ff ff ff 48 c7 c1 c4 c8 e3 8d 80 e1 07 80 c1 03 38 c1
RSP: 0018:ffffc90003ec72a0 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 1ffff920007d8e58 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000201 RDI: ffffffff884eb75b
RBP: ffffc90003ec7358 R08: dffffc0000000000 R09: ffffed10036d9836
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff88801a826280 R14: ffffc90003ec72e0 R15: 0000000000000201
 __sock_map_delete net/core/sock_map.c:426 [inline]
 sock_map_delete_elem+0xcb/0x130 net/core/sock_map.c:448
 bpf_prog_2c29ac5cdc6b1842+0x3a/0x154
 bpf_dispatcher_nop_func include/linux/bpf.h:785 [inline]
 __bpf_prog_run include/linux/filter.h:628 [inline]
 bpf_prog_run include/linux/filter.h:635 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:1880 [inline]
 bpf_trace_run1+0x168/0x2f0 kernel/trace/bpf_trace.c:1916
 __bpf_trace_mm_page_free_batched+0x41/0x60 include/trace/events/kmem.h:182
 trace_mm_page_free_batched include/trace/events/kmem.h:182 [inline]
 free_unref_page_list+0x79b/0x8e0 mm/page_alloc.c:3465
 release_pages+0x1bb9/0x1f40 mm/swap.c:963
 __pagevec_release+0x80/0xf0 mm/swap.c:983
 pagevec_release include/linux/pagevec.h:81 [inline]
 shmem_undo_range+0x67a/0x1b50 mm/shmem.c:964
 shmem_truncate_range mm/shmem.c:1063 [inline]
 shmem_evict_inode+0x21b/0xa00 mm/shmem.c:1145
 evict+0x2a4/0x620 fs/inode.c:587
 __dentry_kill+0x436/0x650 fs/dcache.c:582
 dentry_kill+0xbb/0x290
 dput+0xd8/0x1a0 fs/dcache.c:889
 do_renameat2+0xe1c/0x1700 fs/namei.c:4987
 __do_sys_rename fs/namei.c:5031 [inline]
 __se_sys_rename fs/namei.c:5029 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5029
 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:0x7f8aff3c293b
Code: 48 8b 15 f0 64 15 00 83 c8 ff 64 83 3a 15 75 0e 48 8b 7c 24 08 e8 d5 d4 07 00 f7 d8 19 c0 48 83 c4 18 c3 b8 52 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 10 48 8b 15 be 64 15 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffe783b26b8 EFLAGS: 00000206 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 000055d4cab46101 RCX: 00007f8aff3c293b
RDX: 000055d196a5fa03 RSI: 00007ffe783b26d8 RDI: 00007ffe783b2ad8
RBP: 000055d4cbe712c0 R08: 0000000000000006 R09: 80b8a5cf17706539
R10: 000000000000010f R11: 0000000000000206 R12: 000055d4cbea3120
R13: 00007ffe783b26d8 R14: 00007ffe783b2ad8 R15: 000055d4cab30ec8
 </TASK>
WARNING: CPU: 0 PID: 7989 at kernel/softirq.c:363 __local_bh_enable_ip+0x1b3/0x1f0
Modules linked in:
CPU: 0 PID: 7989 Comm: udevd Not tainted 5.15.153-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:__local_bh_enable_ip+0x1b3/0x1f0 kernel/softirq.c:363
Code: 04 25 28 00 00 00 48 3b 44 24 60 75 4a 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b e9 d0 fe ff ff e8 3f 00 00 00 eb a2 <0f> 0b e9 02 ff ff ff 48 c7 c1 c4 c8 e3 8d 80 e1 07 80 c1 03 38 c1
RSP: 0018:ffffc90003ec72a0 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 1ffff920007d8e58 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000201 RDI: ffffffff884eb75b
RBP: ffffc90003ec7358 R08: dffffc0000000000 R09: ffffed10036d9836
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff88801a826280 R14: ffffc90003ec72e0 R15: 0000000000000201
FS:  00007f8aff313c80(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2f223000 CR3: 0000000079e54000 CR4: 00000000003506f0
Call Trace:
 <TASK>
 __sock_map_delete net/core/sock_map.c:426 [inline]
 sock_map_delete_elem+0xcb/0x130 net/core/sock_map.c:448
 bpf_prog_2c29ac5cdc6b1842+0x3a/0x154
 bpf_dispatcher_nop_func include/linux/bpf.h:785 [inline]
 __bpf_prog_run include/linux/filter.h:628 [inline]
 bpf_prog_run include/linux/filter.h:635 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:1880 [inline]
 bpf_trace_run1+0x168/0x2f0 kernel/trace/bpf_trace.c:1916
 __bpf_trace_mm_page_free_batched+0x41/0x60 include/trace/events/kmem.h:182
 trace_mm_page_free_batched include/trace/events/kmem.h:182 [inline]
 free_unref_page_list+0x79b/0x8e0 mm/page_alloc.c:3465
 release_pages+0x1bb9/0x1f40 mm/swap.c:963
 __pagevec_release+0x80/0xf0 mm/swap.c:983
 pagevec_release include/linux/pagevec.h:81 [inline]
 shmem_undo_range+0x67a/0x1b50 mm/shmem.c:964
 shmem_truncate_range mm/shmem.c:1063 [inline]
 shmem_evict_inode+0x21b/0xa00 mm/shmem.c:1145
 evict+0x2a4/0x620 fs/inode.c:587
 __dentry_kill+0x436/0x650 fs/dcache.c:582
 dentry_kill+0xbb/0x290
 dput+0xd8/0x1a0 fs/dcache.c:889
 do_renameat2+0xe1c/0x1700 fs/namei.c:4987
 __do_sys_rename fs/namei.c:5031 [inline]
 __se_sys_rename fs/namei.c:5029 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5029
 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:0x7f8aff3c293b
Code: 48 8b 15 f0 64 15 00 83 c8 ff 64 83 3a 15 75 0e 48 8b 7c 24 08 e8 d5 d4 07 00 f7 d8 19 c0 48 83 c4 18 c3 b8 52 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 10 48 8b 15 be 64 15 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffe783b26b8 EFLAGS: 00000206
 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 000055d4cab46101 RCX: 00007f8aff3c293b
RDX: 000055d196a5fa03 RSI: 00007ffe783b26d8 RDI: 00007ffe783b2ad8
RBP: 000055d4cbe712c0 R08: 0000000000000006 R09: 80b8a5cf17706539
R10: 000000000000010f R11: 0000000000000206 R12: 000055d4cbea3120
R13: 00007ffe783b26d8 R14: 00007ffe783b2ad8 R15: 000055d4cab30ec8
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/04 02:53 linux-5.15.y 9465fef4ae35 51c4dcff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in get_page_from_freelist
* Struck through repros no longer work on HEAD.