[v6.6] possible deadlock in try_charge_memcg

5 views
Skip to first unread message

syzbot

unread,
Jul 30, 2026, 2:53:27 AMJul 30
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ae068b676196 Linux 6.6.146
git tree: linux-6.6.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17e3b1b9580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f0bc3d90c30838b5
dashboard link: https://syzkaller.appspot.com/bug?extid=0c89eaef77f3a3816749
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/46bfcd1ce0e6/disk-ae068b67.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/df911bf6c2f3/vmlinux-ae068b67.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e1345d6d2d96/bzImage-ae068b67.xz

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

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.0.362/6714 is trying to acquire lock:
ffff8880b8f37de8 (stock_lock){-.-.}-{2:2}, at: local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
ffff8880b8f37de8 (stock_lock){-.-.}-{2:2}, at: consume_stock mm/memcontrol.c:2274 [inline]
ffff8880b8f37de8 (stock_lock){-.-.}-{2:2}, at: try_charge_memcg+0x21a/0x17c0 mm/memcontrol.c:2684

but task is already holding lock:
ffff88804da34238 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc4/0xd60 kernel/bpf/lpm_trie.c:335

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&trie->lock){-.-.}-{2:2}:
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xb4/0x100 kernel/locking/spinlock.c:162
trie_delete_elem+0x94/0x630 kernel/bpf/lpm_trie.c:466
0xffffffffa000099e
bpf_dispatcher_nop_func include/linux/bpf.h:1224 [inline]
__bpf_prog_run include/linux/filter.h:617 [inline]
bpf_prog_run include/linux/filter.h:624 [inline]
bpf_prog_run_array include/linux/bpf.h:1994 [inline]
trace_call_bpf+0x333/0x6c0 kernel/trace/bpf_trace.c:143
perf_trace_run_bpf_submit+0x7a/0x1c0 kernel/events/core.c:10287
perf_trace_lock_acquire+0x342/0x400 include/trace/events/lock.h:24
trace_lock_acquire include/trace/events/lock.h:24 [inline]
lock_acquire+0x3ef/0x420 kernel/locking/lockdep.c:5725
rcu_lock_acquire include/linux/rcupdate.h:334 [inline]
rcu_read_lock include/linux/rcupdate.h:786 [inline]
percpu_ref_put_many include/linux/percpu-refcount.h:330 [inline]
percpu_ref_put+0x35/0x180 include/linux/percpu-refcount.h:351
css_put include/linux/cgroup_refcnt.h:79 [inline]
drain_stock mm/memcontrol.c:2304 [inline]
__refill_stock+0x12a/0x3d0 mm/memcontrol.c:2341
refill_stock+0x19e/0x450 mm/memcontrol.c:2356
try_charge_memcg+0x1281/0x17c0 mm/memcontrol.c:2807
try_charge mm/memcontrol.c:2865 [inline]
charge_memcg+0x11b/0x3b0 mm/memcontrol.c:7090
__mem_cgroup_charge+0x25/0x80 mm/memcontrol.c:7111
mem_cgroup_charge include/linux/memcontrol.h:686 [inline]
wp_page_copy mm/memory.c:3118 [inline]
do_wp_page+0x1378/0x34d0 mm/memory.c:3469
handle_pte_fault mm/memory.c:5063 [inline]
__handle_mm_fault mm/memory.c:5188 [inline]
handle_mm_fault+0x1306/0x4a50 mm/memory.c:5353
do_user_addr_fault+0x736/0x12d0 arch/x86/mm/fault.c:1371
handle_page_fault arch/x86/mm/fault.c:1463 [inline]
exc_page_fault+0x64/0x100 arch/x86/mm/fault.c:1516
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:608
__put_user_4+0x11/0x20 arch/x86/lib/putuser.S:87
schedule_tail+0x93/0xb0 kernel/sched/core.c:5317
ret_from_fork+0x24/0x80 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #0 (stock_lock){-.-.}-{2:2}:
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
consume_stock mm/memcontrol.c:2274 [inline]
try_charge_memcg+0x237/0x17c0 mm/memcontrol.c:2684
obj_cgroup_charge_pages mm/memcontrol.c:3138 [inline]
__memcg_kmem_charge_page+0x224/0x380 mm/memcontrol.c:3164
__alloc_pages+0x222/0x460 mm/page_alloc.c:4518
__alloc_pages_node include/linux/gfp.h:237 [inline]
alloc_pages_node include/linux/gfp.h:260 [inline]
__kmalloc_large_node+0x8c/0x1f0 mm/slab_common.c:1148
__do_kmalloc_node mm/slab_common.c:995 [inline]
__kmalloc_node+0x112/0x240 mm/slab_common.c:1014
kmalloc_node include/linux/slab.h:620 [inline]
bpf_map_kmalloc_node+0xbc/0x1b0 kernel/bpf/syscall.c:424
lpm_trie_node_alloc kernel/bpf/lpm_trie.c:291 [inline]
trie_update_elem+0x172/0xd60 kernel/bpf/lpm_trie.c:338
bpf_map_update_value+0x64b/0x710 kernel/bpf/syscall.c:203
generic_map_update_batch+0x5de/0x800 kernel/bpf/syscall.c:1800
bpf_map_do_batch+0x3f2/0x600 kernel/bpf/syscall.c:5011
__sys_bpf+0x381/0x890 kernel/bpf/syscall.c:-1
__do_sys_bpf kernel/bpf/syscall.c:5582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5580 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5580
do_syscall_x64 arch/x86/entry/common.c:46 [inline]
do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&trie->lock);
lock(stock_lock);
lock(&trie->lock);
lock(stock_lock);

*** DEADLOCK ***

2 locks held by syz.0.362/6714:
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:334 [inline]
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:786 [inline]
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x408/0x710 kernel/bpf/syscall.c:202
#1: ffff88804da34238 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc4/0xd60 kernel/bpf/lpm_trie.c:335

stack backtrace:
CPU: 1 PID: 6714 Comm: syz.0.362 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0x18c/0x250 lib/dump_stack.c:106
check_noncircular+0x2fc/0x400 kernel/locking/lockdep.c:2187
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
consume_stock mm/memcontrol.c:2274 [inline]
try_charge_memcg+0x237/0x17c0 mm/memcontrol.c:2684
obj_cgroup_charge_pages mm/memcontrol.c:3138 [inline]
__memcg_kmem_charge_page+0x224/0x380 mm/memcontrol.c:3164
__alloc_pages+0x222/0x460 mm/page_alloc.c:4518
__alloc_pages_node include/linux/gfp.h:237 [inline]
alloc_pages_node include/linux/gfp.h:260 [inline]
__kmalloc_large_node+0x8c/0x1f0 mm/slab_common.c:1148
__do_kmalloc_node mm/slab_common.c:995 [inline]
__kmalloc_node+0x112/0x240 mm/slab_common.c:1014
kmalloc_node include/linux/slab.h:620 [inline]
bpf_map_kmalloc_node+0xbc/0x1b0 kernel/bpf/syscall.c:424
lpm_trie_node_alloc kernel/bpf/lpm_trie.c:291 [inline]
trie_update_elem+0x172/0xd60 kernel/bpf/lpm_trie.c:338
bpf_map_update_value+0x64b/0x710 kernel/bpf/syscall.c:203
generic_map_update_batch+0x5de/0x800 kernel/bpf/syscall.c:1800
bpf_map_do_batch+0x3f2/0x600 kernel/bpf/syscall.c:5011
__sys_bpf+0x381/0x890 kernel/bpf/syscall.c:-1
__do_sys_bpf kernel/bpf/syscall.c:5582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5580 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5580
do_syscall_x64 arch/x86/entry/common.c:46 [inline]
do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7fc1e9d9df99
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc1eacaf028 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fc1ea025fa0 RCX: 00007fc1e9d9df99
RDX: 0000000000000038 RSI: 0000200000000080 RDI: 000000000000001a
RBP: 00007fc1e9e34ec4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fc1ea026038 R14: 00007fc1ea025fa0 R15: 00007ffe559c9918
</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 report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

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

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

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

syzbot

unread,
Aug 16, 2026, 3:45:34 AMAug 16
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: d27334b2888c Linux 6.6.151
git tree: linux-6.6.y
console output: https://syzkaller.appspot.com/x/log.txt?x=156e9a79580000
kernel config: https://syzkaller.appspot.com/x/.config?x=f0bc3d90c30838b5
dashboard link: https://syzkaller.appspot.com/bug?extid=0c89eaef77f3a3816749
compiler: Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12beaa25580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12621949580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9a1d918615bf/disk-d27334b2.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/260a7d847a41/vmlinux-d27334b2.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f3813e89b404/bzImage-d27334b2.xz

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

======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Not tainted
------------------------------------------------------
syz.0.17/5940 is trying to acquire lock:
ffff8880b8e37de8 (stock_lock){..-.}-{2:2}, at: local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
ffff8880b8e37de8 (stock_lock){..-.}-{2:2}, at: consume_stock mm/memcontrol.c:2274 [inline]
ffff8880b8e37de8 (stock_lock){..-.}-{2:2}, at: try_charge_memcg+0x21a/0x17c0 mm/memcontrol.c:2684

but task is already holding lock:
ffff88801bad4a38 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc4/0xd60 kernel/bpf/lpm_trie.c:335

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&trie->lock){-.-.}-{2:2}:
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xb4/0x100 kernel/locking/spinlock.c:162
trie_delete_elem+0x94/0x630 kernel/bpf/lpm_trie.c:466
bpf_prog_2c29ac5cdc6b1842+0x42/0x46
bpf_dispatcher_nop_func include/linux/bpf.h:1224 [inline]
__bpf_prog_run include/linux/filter.h:617 [inline]
bpf_prog_run include/linux/filter.h:624 [inline]
bpf_prog_run_array include/linux/bpf.h:1994 [inline]
trace_call_bpf+0x333/0x6c0 kernel/trace/bpf_trace.c:143
perf_trace_run_bpf_submit+0x7a/0x1c0 kernel/events/core.c:10287
perf_trace_lock_acquire+0x342/0x400 include/trace/events/lock.h:24
trace_lock_acquire include/trace/events/lock.h:24 [inline]
lock_acquire+0x3ef/0x420 kernel/locking/lockdep.c:5725
rcu_lock_acquire include/linux/rcupdate.h:334 [inline]
rcu_read_lock include/linux/rcupdate.h:786 [inline]
mod_objcg_mlstate+0xad/0x320 mm/memcontrol.c:2913
mod_objcg_state+0x44b/0x8c0 mm/memcontrol.c:3254
memcg_slab_free_hook+0x167/0x200 mm/slab.h:577
slab_free mm/slub.c:3825 [inline]
__kmem_cache_free+0xa3/0x1f0 mm/slub.c:3843
rcu_do_batch kernel/rcu/tree.c:2194 [inline]
rcu_core+0x9c1/0x17f0 kernel/rcu/tree.c:2467
handle_softirqs+0x27d/0x820 kernel/softirq.c:578
run_ksoftirqd+0xa8/0x100 kernel/softirq.c:950
smpboot_thread_fn+0x651/0x9f0 kernel/smpboot.c:164
kthread+0x2fa/0x390 kernel/kthread.c:388
ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:152
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:293

-> #0 (stock_lock){..-.}-{2:2}:
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain kernel/locking/lockdep.c:3869 [inline]
__lock_acquire+0x37ef/0x7d80 kernel/locking/lockdep.c:5137
lock_acquire+0x19e/0x420 kernel/locking/lockdep.c:5754
local_lock_acquire include/linux/local_lock_internal.h:29 [inline]
consume_stock mm/memcontrol.c:2274 [inline]
try_charge_memcg+0x237/0x17c0 mm/memcontrol.c:2684
obj_cgroup_charge_pages mm/memcontrol.c:3138 [inline]
__memcg_kmem_charge_page+0x224/0x380 mm/memcontrol.c:3164
__alloc_pages+0x222/0x460 mm/page_alloc.c:4518
__alloc_pages_node include/linux/gfp.h:237 [inline]
alloc_pages_node include/linux/gfp.h:260 [inline]
__kmalloc_large_node+0x8c/0x1f0 mm/slab_common.c:1148
__do_kmalloc_node mm/slab_common.c:995 [inline]
__kmalloc_node+0x112/0x240 mm/slab_common.c:1014
kmalloc_node include/linux/slab.h:620 [inline]
bpf_map_kmalloc_node+0xbc/0x1b0 kernel/bpf/syscall.c:424
lpm_trie_node_alloc kernel/bpf/lpm_trie.c:291 [inline]
trie_update_elem+0x172/0xd60 kernel/bpf/lpm_trie.c:338
bpf_map_update_value+0x64b/0x710 kernel/bpf/syscall.c:203
map_update_elem+0x586/0x710 kernel/bpf/syscall.c:1567
__sys_bpf+0x6b5/0x890 kernel/bpf/syscall.c:5466
__do_sys_bpf kernel/bpf/syscall.c:5582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5580 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5580
do_syscall_x64 arch/x86/entry/common.c:46 [inline]
do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&trie->lock);
lock(stock_lock);
lock(&trie->lock);
lock(stock_lock);

*** DEADLOCK ***

2 locks held by syz.0.17/5940:
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:334 [inline]
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:786 [inline]
#0: ffffffff8d131da0 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x408/0x710 kernel/bpf/syscall.c:202
#1: ffff88801bad4a38 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc4/0xd60 kernel/bpf/lpm_trie.c:335

stack backtrace:
CPU: 0 PID: 5940 Comm: syz.0.17 Not tainted syzkaller #0
map_update_elem+0x586/0x710 kernel/bpf/syscall.c:1567
__sys_bpf+0x6b5/0x890 kernel/bpf/syscall.c:5466
__do_sys_bpf kernel/bpf/syscall.c:5582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5580 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5580
do_syscall_x64 arch/x86/entry/common.c:46 [inline]
do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:76
entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f4530d9e0d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdbf9d3038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f4531025fa0 RCX: 00007f4530d9e0d9
RDX: 0000000000000020 RSI: 0000200000000080 RDI: 0000000000000002
RBP: 00007f4530e35024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f4531025fac R14: 00007f4531025fa0 R15: 00007f4531025fa0
</TASK>


---
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.
Reply all
Reply to author
Forward
0 new messages