[moderation] [cgroups?] [mm?] KCSAN: data-race in __count_memcg_events / mem_cgroup_css_rstat_flush

3 views
Skip to first unread message

syzbot

unread,
Feb 11, 2024, 6:46:25 AMFeb 11
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 7521f258ea30 Merge tag 'mm-hotfixes-stable-2024-02-10-11-1..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16faeaec180000
kernel config: https://syzkaller.appspot.com/x/.config?x=3cd0dc1b46a5bc5c
dashboard link: https://syzkaller.appspot.com/bug?extid=8f212b33c3749fb70713
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
CC: [ak...@linux-foundation.org cgr...@vger.kernel.org han...@cmpxchg.org linux-...@vger.kernel.org linu...@kvack.org mho...@kernel.org muchu...@linux.dev roman.g...@linux.dev shak...@google.com]

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/13bab0f1fd7a/disk-7521f258.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b8ba502ce3fb/vmlinux-7521f258.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1a60cc363ef5/bzImage-7521f258.xz

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

oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=syz3,mems_allowed=0,oom_memcg=/syz3,task_memcg=/syz3,task=syz-executor.3,pid=11770,uid=0
Memory cgroup out of memory: Killed process 11770 (syz-executor.3) total-vm:48624kB, anon-rss:516kB, file-rss:8320kB, shmem-rss:0kB, UID:0 pgtables:76kB oom_score_adj:1000
==================================================================
BUG: KCSAN: data-race in __count_memcg_events / mem_cgroup_css_rstat_flush

write to 0xffffe8ffffc4b340 of 4 bytes by task 18940 on cpu 1:
mem_cgroup_css_rstat_flush+0x4ea/0x540 mm/memcontrol.c:5845
cgroup_rstat_flush_locked+0x86b/0x9a0 kernel/cgroup/rstat.c:245
cgroup_rstat_flush+0x26/0x40 kernel/cgroup/rstat.c:277
do_flush_stats mm/memcontrol.c:744 [inline]
mem_cgroup_flush_stats+0xb2/0xc0 mm/memcontrol.c:765
prepare_scan_control mm/vmscan.c:2226 [inline]
shrink_node+0x314/0x15d0 mm/vmscan.c:5900
shrink_zones mm/vmscan.c:6141 [inline]
do_try_to_free_pages+0x43d/0xce0 mm/vmscan.c:6203
try_to_free_mem_cgroup_pages+0x1e2/0x480 mm/vmscan.c:6518
try_charge_memcg+0x280/0xd20 mm/memcontrol.c:2782
obj_cgroup_charge_pages+0xbd/0x1c0 mm/memcontrol.c:3301
__memcg_kmem_charge_page+0x9c/0x170 mm/memcontrol.c:3327
__alloc_pages+0x1bb/0x340 mm/page_alloc.c:4584
alloc_pages_mpol+0xb1/0x1d0 mm/mempolicy.c:2133
alloc_pages+0xe0/0x100 mm/mempolicy.c:2204
vm_area_alloc_pages mm/vmalloc.c:3063 [inline]
__vmalloc_area_node mm/vmalloc.c:3139 [inline]
__vmalloc_node_range+0x6ee/0xec0 mm/vmalloc.c:3320
__bpf_map_area_alloc kernel/bpf/syscall.c:306 [inline]
bpf_map_area_alloc+0xd8/0x100 kernel/bpf/syscall.c:313
bloom_map_alloc+0x1aa/0x2b0 kernel/bpf/bloom_filter.c:134
map_create+0x713/0xa40 kernel/bpf/syscall.c:1237
__sys_bpf+0x62a/0x780 kernel/bpf/syscall.c:5439
__do_sys_bpf kernel/bpf/syscall.c:5561 [inline]
__se_sys_bpf kernel/bpf/syscall.c:5559 [inline]
__x64_sys_bpf+0x43/0x50 kernel/bpf/syscall.c:5559
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xcd/0x1d0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

read-write to 0xffffe8ffffc4b340 of 4 bytes by task 18939 on cpu 0:
memcg_rstat_updated mm/memcontrol.c:724 [inline]
__count_memcg_events+0xd1/0x130 mm/memcontrol.c:961
shrink_active_list+0x62a/0x820 mm/vmscan.c:2074
shrink_list mm/vmscan.c:2149 [inline]
shrink_lruvec+0x993/0x17a0 mm/vmscan.c:5681
shrink_node_memcgs mm/vmscan.c:5867 [inline]
shrink_node+0xac3/0x15d0 mm/vmscan.c:5902
shrink_zones mm/vmscan.c:6141 [inline]
do_try_to_free_pages+0x43d/0xce0 mm/vmscan.c:6203
try_to_free_mem_cgroup_pages+0x1e2/0x480 mm/vmscan.c:6518
try_charge_memcg+0x280/0xd20 mm/memcontrol.c:2782
try_charge mm/memcontrol.c:2930 [inline]
charge_memcg mm/memcontrol.c:7276 [inline]
mem_cgroup_swapin_charge_folio+0x107/0x190 mm/memcontrol.c:7361
__read_swap_cache_async+0x2b9/0x510 mm/swap_state.c:498
swap_cluster_readahead+0x276/0x3f0 mm/swap_state.c:662
swapin_readahead+0xe2/0x7a0 mm/swap_state.c:886
do_swap_page+0x439/0x1530 mm/memory.c:3898
handle_pte_fault mm/memory.c:5147 [inline]
__handle_mm_fault mm/memory.c:5285 [inline]
handle_mm_fault+0x7f6/0x27c0 mm/memory.c:5450
do_user_addr_fault arch/x86/mm/fault.c:1415 [inline]
handle_page_fault arch/x86/mm/fault.c:1507 [inline]
exc_page_fault+0x2f9/0x6d0 arch/x86/mm/fault.c:1563
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
__get_user_8+0x11/0x20 arch/x86/lib/getuser.S:85
rseq_get_rseq_cs kernel/rseq.c:161 [inline]
rseq_ip_fixup kernel/rseq.c:281 [inline]
__rseq_handle_notify_resume+0xc7/0xbf0 kernel/rseq.c:329
rseq_handle_notify_resume include/linux/rseq.h:38 [inline]
resume_user_mode_work include/linux/resume_user_mode.h:62 [inline]
exit_to_user_mode_loop kernel/entry/common.c:108 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
irqentry_exit_to_user_mode+0xd3/0x130 kernel/entry/common.c:225
irqentry_exit+0x12/0x40 kernel/entry/common.c:328
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570

value changed: 0x00000002 -> 0x00000000

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 18939 Comm: syz-executor.3 Tainted: G W 6.8.0-rc3-syzkaller-00317-g7521f258ea30 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
==================================================================
syz-executor.3 invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=1000
CPU: 0 PID: 18939 Comm: syz-executor.3 Tainted: G W 6.8.0-rc3-syzkaller-00317-g7521f258ea30 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
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+0x82/0x2d0 mm/oom_kill.c:461
oom_kill_process+0x33a/0x4c0 mm/oom_kill.c:1032
out_of_memory+0x9ca/0xbf0 mm/oom_kill.c:1170
mem_cgroup_out_of_memory+0x139/0x190 mm/memcontrol.c:1816
mem_cgroup_oom mm/memcontrol.c:2046 [inline]
try_charge_memcg+0x759/0xd20 mm/memcontrol.c:2830
try_charge mm/memcontrol.c:2930 [inline]
charge_memcg mm/memcontrol.c:7276 [inline]
mem_cgroup_swapin_charge_folio+0x107/0x190 mm/memcontrol.c:7361
__read_swap_cache_async+0x2b9/0x510 mm/swap_state.c:498
swap_cluster_readahead+0x276/0x3f0 mm/swap_state.c:662
swapin_readahead+0xe2/0x7a0 mm/swap_state.c:886
do_swap_page+0x439/0x1530 mm/memory.c:3898
handle_pte_fault mm/memory.c:5147 [inline]
__handle_mm_fault mm/memory.c:5285 [inline]
handle_mm_fault+0x7f6/0x27c0 mm/memory.c:5450
do_user_addr_fault arch/x86/mm/fault.c:1415 [inline]
handle_page_fault arch/x86/mm/fault.c:1507 [inline]
exc_page_fault+0x2f9/0x6d0 arch/x86/mm/fault.c:1563
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0010:__get_user_8+0x11/0x20 arch/x86/lib/getuser.S:88
Code: 48 c1 fa 3f 48 09 d0 0f 01 cb 8b 10 31 c0 0f 01 ca c3 0f 1f 80 00 00 00 00 f3 0f 1e fa 48 89 c2 48 c1 fa 3f 48 09 d0 0f 01 cb <48> 8b 10 31 c0 0f 01 ca c3 66 0f 1f 44 00 00 f3 0f 1e fa 0f 01 cb
RSP: 0018:ffffc900016afe58 EFLAGS: 00050202
RAX: 0000555556bafda8 RBX: ffffc900016afe60 RCX: ffffffff8144d253
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88810897db10
RBP: ffffc900016aff20 R08: 000188810897db17 R09: 0000000000000000
R10: 0001ffffffffffff R11: 0001c900016afee8 R12: ffff88810897d140
R13: ffff88810897db10 R14: ffffc900016aff58 R15: ffffc900016affd8
rseq_get_rseq_cs kernel/rseq.c:161 [inline]
rseq_ip_fixup kernel/rseq.c:281 [inline]
__rseq_handle_notify_resume+0xc7/0xbf0 kernel/rseq.c:329
rseq_handle_notify_resume include/linux/rseq.h:38 [inline]
resume_user_mode_work include/linux/resume_user_mode.h:62 [inline]
exit_to_user_mode_loop kernel/entry/common.c:108 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
irqentry_exit_to_user_mode+0xd3/0x130 kernel/entry/common.c:225
irqentry_exit+0x12/0x40 kernel/entry/common.c:328
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7fb02bae9da4
Code: 01 00 00 69 3d 11 d9 c9 00 e8 03 00 00 48 8d 1d f2 41 17 00 e8 9d 5f 04 00 eb 0f 0f 1f 00 48 81 c3 d0 00 00 00 48 39 eb 74 be <80> 7b 20 00 74 ee 8b 43 0c 85 c0 74 e7 48 89 df e8 f7 ee ff ff eb
RSP: 002b:00007ffd2b682bc0 EFLAGS: 00010206
RAX: 0000000000000000 RBX: 00007fb02bc5df80 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000555556baf788
RBP: 00007fb02bc5f980 R08: 0000000000000000 R09: 00007ffd2b7030b0
R10: 0000000000000000 R11: 0000000000000293 R12: 00000000000604da
R13: ffffffffffffffff R14: 00007fb02b6b2000 R15: 0000000000060199
</TASK>
memory: usage 307200kB, limit 307200kB, failcnt 3940
memory+swap: usage 311536kB, limit 9007199254740988kB, failcnt 0
kmem: usage 301596kB, limit 9007199254740988kB, failcnt 0
Memory cgroup stats for /syz3:
cache 40960
rss 0
shmem 0
mapped_file 0
dirty 20480
writeback 0
workingset_refault_anon 10
workingset_refault_file 6
swap 4448256
swapcached 8192
pgpgin 126771
pgpgout 126759
pgfault 196988
pgmajfault 11
inactive_anon 8192
active_anon 0
inactive_file 16384
active_file 24576
unevictable 0
hierarchical_memory_limit 314572800
hierarchical_memsw_limit 9223372036854771712
total_cache 40960
total_rss 0
total_shmem 0
total_mapped_file 0
total_dirty 20480
total_writeback 0
total_workingset_refault_anon 10
total_workingset_refault_file 6
total_swap 4448256
total_swapcached 8192
total_pgpgin 126771
total_pgpgout 126759
total_pgfault 196988
total_pgmajfault 11
total_inactive_anon 8192
total_active_anon 0
total_inactive_file 16384
total_active_file 24576
total_unevictable 0
oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=syz3,mems_allowed=0,oom_memcg=/syz3,task_memcg=/syz3,task=syz-executor.3,pid=11796,uid=0
Memory cgroup out of memory: Killed process 11796 (syz-executor.3) total-vm:48624kB, anon-rss:500kB, file-rss:8320kB, shmem-rss:0kB, UID:0 pgtables:76kB oom_score_adj:1000
syz-executor.3 (18939) used greatest stack depth: 9592 bytes left
----------------
Code disassembly (best guess):
0: 48 c1 fa 3f sar $0x3f,%rdx
4: 48 09 d0 or %rdx,%rax
7: 0f 01 cb stac
a: 8b 10 mov (%rax),%edx
c: 31 c0 xor %eax,%eax
e: 0f 01 ca clac
11: c3 ret
12: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
19: f3 0f 1e fa endbr64
1d: 48 89 c2 mov %rax,%rdx
20: 48 c1 fa 3f sar $0x3f,%rdx
24: 48 09 d0 or %rdx,%rax
27: 0f 01 cb stac
* 2a: 48 8b 10 mov (%rax),%rdx <-- trapping instruction
2d: 31 c0 xor %eax,%eax
2f: 0f 01 ca clac
32: c3 ret
33: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
39: f3 0f 1e fa endbr64
3d: 0f 01 cb stac


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