syzbot


KCSAN: data-race in drain_all_stock / try_charge_memcg

Status: auto-closed as invalid on 2021/12/07 05:48
Subsystems: cgroups mm
[Documentation on labels]
First crash: 920d, last: 920d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in drain_all_stock / try_charge_memcg (2) mm cgroups 189 3d03h 154d 0/26 moderation: reported on 2023/12/08 00:06

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

write to 0xffff888237c22fe8 of 8 bytes by task 24335 on cpu 0:
 refill_stock mm/memcontrol.c:2221 [inline]
 try_charge_memcg+0x846/0xa10 mm/memcontrol.c:2683
 obj_cgroup_charge_pages+0xce/0x210 mm/memcontrol.c:2974
 obj_cgroup_charge+0xe2/0x1b0 mm/memcontrol.c:3256
 memcg_slab_pre_alloc_hook mm/slab.h:287 [inline]
 slab_pre_alloc_hook mm/slab.h:497 [inline]
 slab_alloc_node mm/slab.c:3222 [inline]
 kmem_cache_alloc_node+0xae/0x2d0 mm/slab.c:3599
 alloc_task_struct_node kernel/fork.c:170 [inline]
 dup_task_struct+0x63/0x680 kernel/fork.c:882
 copy_process+0x3f4/0x2f30 kernel/fork.c:2025
 kernel_clone+0x15c/0x6a0 kernel/fork.c:2583
 __do_sys_clone kernel/fork.c:2700 [inline]
 __se_sys_clone kernel/fork.c:2684 [inline]
 __x64_sys_clone+0xc6/0xf0 kernel/fork.c:2684
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

read to 0xffff888237c22fe8 of 8 bytes by task 24330 on cpu 1:
 drain_all_stock+0xbc/0x4b0 mm/memcontrol.c:2255
 try_charge_memcg+0x6bc/0xa10 mm/memcontrol.c:2616
 try_charge mm/memcontrol.c:2736 [inline]
 charge_memcg+0x51/0x1a0 mm/memcontrol.c:6707
 __mem_cgroup_charge+0x25/0xa0 mm/memcontrol.c:6728
 mem_cgroup_charge include/linux/memcontrol.h:720 [inline]
 __filemap_add_folio+0x3a8/0x4d0 mm/filemap.c:891
 filemap_add_folio+0x6b/0x150 mm/filemap.c:984
 add_to_page_cache_lru+0x4e/0x70 mm/folio-compat.c:115
 page_cache_ra_unbounded+0x274/0x430 mm/readahead.c:221
 ondemand_readahead+0x4f8/0x700
 page_cache_sync_ra+0xaf/0xe0 mm/readahead.c:579
 page_cache_sync_readahead include/linux/pagemap.h:980 [inline]
 filemap_get_pages mm/filemap.c:2541 [inline]
 filemap_read+0x3d8/0x1720 mm/filemap.c:2624
 generic_file_read_iter+0x75/0x2c0 mm/filemap.c:2775
 ext4_file_read_iter+0x1db/0x290
 call_read_iter include/linux/fs.h:2155 [inline]
 new_sync_read fs/read_write.c:400 [inline]
 vfs_read+0x66c/0x750 fs/read_write.c:481
 ksys_read+0xd9/0x190 fs/read_write.c:619
 __do_sys_read fs/read_write.c:629 [inline]
 __se_sys_read fs/read_write.c:627 [inline]
 __x64_sys_read+0x3e/0x50 fs/read_write.c:627
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

value changed: 0x0000000000000000 -> 0xffff88813155c000

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 24330 Comm: syz-executor.2 Not tainted 5.15.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
==================================================================
syz-executor.2 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=0, oom_score_adj=1000
CPU: 0 PID: 24330 Comm: syz-executor.2 Not tainted 5.15.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd6/0x122 lib/dump_stack.c:106
 dump_stack+0x11/0x1b lib/dump_stack.c:113
 dump_header+0x98/0x410 mm/oom_kill.c:463
 oom_kill_process+0x18e/0x3f0 mm/oom_kill.c:980
 out_of_memory+0x5ed/0x890 mm/oom_kill.c:1117
 mem_cgroup_out_of_memory mm/memcontrol.c:1579 [inline]
 mem_cgroup_oom+0x484/0x520 mm/memcontrol.c:1814
 try_charge_memcg+0x736/0xa10 mm/memcontrol.c:2655
 try_charge mm/memcontrol.c:2736 [inline]
 charge_memcg+0x51/0x1a0 mm/memcontrol.c:6707
 __mem_cgroup_charge+0x25/0xa0 mm/memcontrol.c:6728
 mem_cgroup_charge include/linux/memcontrol.h:720 [inline]
 __filemap_add_folio+0x3a8/0x4d0 mm/filemap.c:891
 filemap_add_folio+0x6b/0x150 mm/filemap.c:984
 add_to_page_cache_lru+0x4e/0x70 mm/folio-compat.c:115
 filemap_create_page mm/filemap.c:2490 [inline]
 filemap_get_pages mm/filemap.c:2548 [inline]
 filemap_read+0x80e/0x1720 mm/filemap.c:2624
 generic_file_read_iter+0x75/0x2c0 mm/filemap.c:2775
 ext4_file_read_iter+0x1db/0x290
 call_read_iter include/linux/fs.h:2155 [inline]
 new_sync_read fs/read_write.c:400 [inline]
 vfs_read+0x66c/0x750 fs/read_write.c:481
 ksys_read+0xd9/0x190 fs/read_write.c:619
 __do_sys_read fs/read_write.c:629 [inline]
 __se_sys_read fs/read_write.c:627 [inline]
 __x64_sys_read+0x3e/0x50 fs/read_write.c:627
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f2e21c2aae9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2e1f9a1188 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f2e21d3df60 RCX: 00007f2e21c2aae9
RDX: 00000000fffffe47 RSI: 0000000020000180 RDI: 0000000000000005
RBP: 00007f2e21c84f25 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffca696e22f R14: 00007f2e1f9a1300 R15: 0000000000022000
memory: usage 307200kB, limit 307200kB, failcnt 59132
swap: usage 0kB, limit 9007199254740988kB, failcnt 0
Memory cgroup stats for /syz2:
anon 2412544
file 306618368
kernel_stack 327680
pagetables 2129920
percpu 0
sock 0
shmem 306561024
file_mapped 0
file_dirty 0
file_writeback 0
swapcached 0
inactive_anon 5681152
active_anon 303280128
inactive_file 0
active_file 0
unevictable 12288
slab_reclaimable 1265320
slab_unreclaimable 1427872
slab 2693192
workingset_refault_anon 0
workingset_refault_file 60801
workingset_activate_anon 0
workingset_activate_file 458
workingset_restore_anon 0
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=syz2,mems_allowed=0,oom_memcg=/syz2,task_memcg=/syz2,task=syz-executor.2,pid=24327,uid=0
Memory cgroup out of memory: Killed process 24330 (syz-executor.2) total-vm:85348kB, anon-rss:692kB, file-rss:35836kB, shmem-rss:0kB, UID:0 pgtables:136kB oom_score_adj:1000

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/02 05:40 upstream e66435936756 098b5d53 .config console log report info ci2-upstream-kcsan-gce KCSAN: data-race in drain_all_stock / try_charge_memcg
* Struck through repros no longer work on HEAD.