syzbot


KCSAN: data-race in drain_all_stock / drain_obj_stock (4)

Status: fixed on 2023/09/28 17:51
Subsystems: cgroups mm
[Documentation on labels]
Reported-by: syzbot+774c29891415ab0fd29d@syzkaller.appspotmail.com
Fix commit: 3b8abb323953 mm: kmem: fix a NULL pointer dereference in obj_stock_flush_required()
First crash: 430d, last: 349d
Discussions (3)
Title Replies (including bot) Last reply
[PATCH v2 1/2] mm: kmem: fix a NULL pointer dereference in obj_stock_flush_required() 7 (7) 2023/05/03 17:04
[PATCH] mm: kmem: fix a NULL pointer dereference in obj_stock_flush_required() 9 (9) 2023/04/24 21:10
[syzbot] [cgroups?] [mm?] KCSAN: data-race in drain_all_stock / drain_obj_stock (4) 1 (2) 2023/04/21 14:38
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in drain_all_stock / drain_obj_stock cgroups mm 1 811d 811d 0/26 auto-closed as invalid on 2022/03/06 02:49
upstream KCSAN: data-race in drain_all_stock / drain_obj_stock (2) cgroups mm 1 758d 758d 0/26 auto-closed as invalid on 2022/04/28 00:32
upstream KCSAN: data-race in drain_all_stock / drain_obj_stock (3) cgroups mm 1 622d 622d 0/26 auto-closed as invalid on 2022/09/10 21:57

Sample crash report:
==================================================================
BUG: KCSAN: data-race in drain_all_stock / drain_obj_stock

write to 0xffff888237c2a4f8 of 8 bytes by task 17546 on cpu 0:
 drain_obj_stock+0x209/0x270 mm/memcontrol.c:3335
 refill_obj_stock+0x7b/0x1d0 mm/memcontrol.c:3369
 obj_cgroup_charge+0x10c/0x140 mm/memcontrol.c:3430
 memcg_slab_pre_alloc_hook mm/slab.h:464 [inline]
 slab_pre_alloc_hook+0x112/0x180 mm/slab.h:675
 slab_alloc_node mm/slab.c:3240 [inline]
 kmem_cache_alloc_node+0x5d/0x2e0 mm/slab.c:3528
 alloc_task_struct_node kernel/fork.c:173 [inline]
 dup_task_struct+0x60/0x480 kernel/fork.c:1108
 copy_process+0x3ac/0x21b0 kernel/fork.c:2333
 kernel_clone+0x169/0x560 kernel/fork.c:2918
 __do_sys_clone kernel/fork.c:3061 [inline]
 __se_sys_clone kernel/fork.c:3045 [inline]
 __x64_sys_clone+0xe8/0x120 kernel/fork.c:3045
 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

read to 0xffff888237c2a4f8 of 8 bytes by task 17534 on cpu 1:
 obj_stock_flush_required mm/memcontrol.c:3348 [inline]
 drain_all_stock+0x179/0x2d0 mm/memcontrol.c:2390
 try_charge_memcg+0x6c2/0xd20 mm/memcontrol.c:2732
 obj_cgroup_charge_pages+0xab/0x130 mm/memcontrol.c:3138
 obj_cgroup_charge+0xe9/0x140 mm/memcontrol.c:3428
 memcg_slab_pre_alloc_hook mm/slab.h:464 [inline]
 slab_pre_alloc_hook+0x112/0x180 mm/slab.h:675
 slab_alloc_node mm/slab.c:3240 [inline]
 kmem_cache_alloc_node+0x5d/0x2e0 mm/slab.c:3528
 alloc_task_struct_node kernel/fork.c:173 [inline]
 dup_task_struct+0x60/0x480 kernel/fork.c:1108
 copy_process+0x3ac/0x21b0 kernel/fork.c:2333
 kernel_clone+0x169/0x560 kernel/fork.c:2918
 __do_sys_clone kernel/fork.c:3061 [inline]
 __se_sys_clone kernel/fork.c:3045 [inline]
 __x64_sys_clone+0xe8/0x120 kernel/fork.c:3045
 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

value changed: 0xffff888138b28dc0 -> 0xffff888138d5cc80

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 17534 Comm: syz-executor.0 Not tainted 6.3.0-syzkaller-13466-gfc4354c6e5c2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
==================================================================
syz-executor.0 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=0, oom_score_adj=1000
CPU: 0 PID: 17534 Comm: syz-executor.0 Not tainted 6.3.0-syzkaller-13466-gfc4354c6e5c2 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xda/0x130 lib/dump_stack.c:106
 dump_stack+0x15/0x20 lib/dump_stack.c:113
 dump_header+0x95/0x3c0 mm/oom_kill.c:460
 oom_kill_process+0xe3/0x3e0 mm/oom_kill.c:1036
 out_of_memory+0x9f0/0xc30 mm/oom_kill.c:1174
 mem_cgroup_out_of_memory+0x139/0x190 mm/memcontrol.c:1749
 mem_cgroup_oom mm/memcontrol.c:1979 [inline]
 try_charge_memcg+0x759/0xd20 mm/memcontrol.c:2772
 obj_cgroup_charge_pages+0xab/0x130 mm/memcontrol.c:3138
 __memcg_kmem_charge_page+0x1d5/0x2c0 mm/memcontrol.c:3164
 memcg_kmem_charge_page include/linux/memcontrol.h:1802 [inline]
 memcg_charge_kernel_stack+0xee/0x290 kernel/fork.c:260
 alloc_thread_stack_node kernel/fork.c:298 [inline]
 dup_task_struct+0x125/0x480 kernel/fork.c:1116
 copy_process+0x3ac/0x21b0 kernel/fork.c:2333
 kernel_clone+0x169/0x560 kernel/fork.c:2918
 __do_sys_clone kernel/fork.c:3061 [inline]
 __se_sys_clone kernel/fork.c:3045 [inline]
 __x64_sys_clone+0xe8/0x120 kernel/fork.c:3045
 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:0x7f48833a5591
Code: 48 85 ff 74 3d 48 85 f6 74 38 48 83 ee 10 48 89 4e 08 48 89 3e 48 89 d7 4c 89 c2 4d 89 c8 4c 8b 54 24 08 b8 38 00 00 00 0f 05 <48> 85 c0 7c 13 74 01 c3 31 ed 58 5f ff d0 48 89 c7 b8 3c 00 00 00
RSP: 002b:00007ffdfe0955d8 EFLAGS: 00000206 ORIG_RAX: 0000000000000038
RAX: ffffffffffffffda RBX: 00007f48826f6700 RCX: 00007f48833a5591
RDX: 00007f48826f69d0 RSI: 00007f48826f62f0 RDI: 00000000003d0f00
RBP: 00007ffdfe095820 R08: 00007f48826f6700 R09: 00007f48826f6700
R10: 00007f48826f69d0 R11: 0000000000000206 R12: 00007ffdfe09568e
R13: 00007ffdfe09568f R14: 00007f48826f6300 R15: 0000000000022000
 </TASK>
memory: usage 307200kB, limit 307200kB, failcnt 49528
swap: usage 0kB, limit 9007199254740988kB, failcnt 0
Memory cgroup stats for /syz0:
anon 237568
file 10412032
kernel 303923200
kernel_stack 49152
pagetables 126976
sec_pagetables 0
percpu 10560288
sock 0
vmalloc 8192
shmem 10412032
file_mapped 94208
file_dirty 0
file_writeback 0
swapcached 0
inactive_anon 237568
active_anon 10412032
inactive_file 0
active_file 0
unevictable 0
slab_reclaimable 35920
slab_unreclaimable 293078784
slab 293114704
workingset_refault_anon 0
workingset_refault_file 55
workingset_activate_anon 0
workingset_activate_file 1
workingset_restore_anon 0
workingset_restore_file 1
workingset_nodereclaim 0
pgscan 548
pgsteal 150
pgscan_kswapd 0
pgscan_direct 548
pgscan_khugepaged 0
pgsteal_kswapd 0
pgsteal_direct 150
pgsteal_khugepaged 0
pgfault 499196
pgmajfault 0
pgrefill 563
pgactivate 23889
pgdeactivate 657
pglazyfree 0
pglazyfreed 0
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=syz0,mems_allowed=0,oom_memcg=/syz0,task_memcg=/syz0,task=syz-executor.0,pid=17534,uid=0
Memory cgroup out of memory: Killed process 17534 (syz-executor.0) total-vm:46484kB, anon-rss:504kB, file-rss:8960kB, shmem-rss:0kB, UID:0 pgtables:84kB oom_score_adj:1000

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/07 12:27 upstream fc4354c6e5c2 90c93c40 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in drain_all_stock / drain_obj_stock
2023/03/19 02:20 upstream 534293368afa 7939252e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in drain_all_stock / drain_obj_stock
2023/02/15 01:34 upstream e1c04510f521 e62ba3c1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in drain_all_stock / drain_obj_stock
* Struck through repros no longer work on HEAD.