syzbot


KASAN: use-after-free Read in pressure_write

Status: upstream: reported on 2025/06/04 19:33
Reported-by: syzbot+b2a476e56082a38911bd@syzkaller.appspotmail.com
First crash: 2d11h, last: 2d11h

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in pressure_write+0x1e3/0x4a0 kernel/cgroup/cgroup.c:3778
Read of size 8 at addr ffff8881437fe608 by task syz.4.480/6641

CPU: 1 PID: 6641 Comm: syz.4.480 Not tainted 6.1.141-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0xa8/0x220 mm/kasan/report.c:427
 kasan_report+0x10b/0x140 mm/kasan/report.c:531
 pressure_write+0x1e3/0x4a0 kernel/cgroup/cgroup.c:3778
 cgroup_file_write+0x2f8/0x660 kernel/cgroup/cgroup.c:4077
 kernfs_fop_write_iter+0x379/0x4c0 fs/kernfs/file.c:334
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x44c/0x960 fs/read_write.c:584
 ksys_write+0x143/0x240 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f0ec258e929
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0ec33a4038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f0ec27b6160 RCX: 00007f0ec258e929
RDX: 000000000000002f RSI: 00002000000001c0 RDI: 0000000000000006
RBP: 00007f0ec2610ab1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0ec27b6160 R15: 00007ffe43752658
 </TASK>

Allocated by task 6641:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x8e/0xa0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 cgroup_file_open+0x85/0x2a0 kernel/cgroup/cgroup.c:4023
 kernfs_fop_open+0xa01/0xcc0 fs/kernfs/file.c:748
 do_dentry_open+0x7e9/0x10d0 fs/open.c:882
 do_open fs/namei.c:3626 [inline]
 path_openat+0x25c6/0x2e70 fs/namei.c:3783
 do_filp_open+0x1c1/0x3c0 fs/namei.c:3810
 do_sys_openat2+0x142/0x490 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x135/0x160 fs/open.c:1345
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 6657:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2d/0x50 mm/kasan/generic.c:516
 ____kasan_slab_free+0x126/0x1e0 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x131/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0xb6/0x1f0 mm/slub.c:3674
 kernfs_release_file+0x128/0x2c0 fs/kernfs/file.c:788
 kernfs_drain_open_files+0x2b4/0x4a0 fs/kernfs/file.c:857
 kernfs_drain+0x4b4/0x660 fs/kernfs/dir.c:513
 __kernfs_remove+0x3f6/0x6d0 fs/kernfs/dir.c:1461
 kernfs_remove_by_name_ns+0xd8/0x150 fs/kernfs/dir.c:1666
 kernfs_remove_by_name include/linux/kernfs.h:622 [inline]
 cgroup_rm_file kernel/cgroup/cgroup.c:1703 [inline]
 cgroup_addrm_files+0x5c6/0xb80 kernel/cgroup/cgroup.c:4270
 cgroup_destroy_locked+0x4d2/0x7f0 kernel/cgroup/cgroup.c:5928
 cgroup_rmdir+0x3c/0x3e0 kernel/cgroup/cgroup.c:5967
 kernfs_iop_rmdir+0x23b/0x3b0 fs/kernfs/dir.c:1239
 vfs_rmdir+0x36c/0x4d0 fs/namei.c:4191
 do_rmdir+0x288/0x5e0 fs/namei.c:4252
 __do_sys_rmdir fs/namei.c:4271 [inline]
 __se_sys_rmdir fs/namei.c:4269 [inline]
 __x64_sys_rmdir+0x45/0x50 fs/namei.c:4269
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:486
 call_rcu+0x14b/0x970 kernel/rcu/tree.c:2845
 tnode_free net/ipv4/fib_trie.c:496 [inline]
 replace+0x237/0x5c0 net/ipv4/fib_trie.c:522
 inflate net/ipv4/fib_trie.c:624 [inline]
 resize+0x1019/0x26e0 net/ipv4/fib_trie.c:869
 trie_rebalance net/ipv4/fib_trie.c:1106 [inline]
 fib_insert_node net/ipv4/fib_trie.c:1150 [inline]
 fib_insert_alias+0xabe/0x1210 net/ipv4/fib_trie.c:1164
 fib_table_insert+0x679/0x1b50 net/ipv4/fib_trie.c:1359
 fib_magic+0x2c1/0x390 net/ipv4/fib_frontend.c:1118
 fib_add_ifaddr+0x140/0x5e0 net/ipv4/fib_frontend.c:1140
 fib_inetaddr_event+0x13c/0x1c0 net/ipv4/fib_frontend.c:1454
 notifier_call_chain kernel/notifier.c:87 [inline]
 blocking_notifier_call_chain+0x103/0x1b0 kernel/notifier.c:382
 __inet_insert_ifa+0x9aa/0xb60 net/ipv4/devinet.c:569
 inet_rtm_newaddr+0x930/0x1890 net/ipv4/devinet.c:971
 rtnetlink_rcv_msg+0x79b/0xed0 net/core/rtnetlink.c:6153
 netlink_rcv_skb+0x1de/0x420 net/netlink/af_netlink.c:2493
 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
 netlink_unicast+0x74c/0x8c0 net/netlink/af_netlink.c:1337
 netlink_sendmsg+0x89e/0xbc0 net/netlink/af_netlink.c:1859
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 __sys_sendto+0x44f/0x5c0 net/socket.c:2153
 __do_sys_sendto net/socket.c:2165 [inline]
 __se_sys_sendto net/socket.c:2161 [inline]
 __x64_sys_sendto+0xda/0xf0 net/socket.c:2161
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff8881437fe600
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 8 bytes inside of
 192-byte region [ffff8881437fe600, ffff8881437fe6c0)

The buggy address belongs to the physical page:
page:ffffea00050dff80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8881437fef00 pfn:0x1437fe
flags: 0x57ff00000000200(slab|node=1|zone=2|lastcpupid=0x7ff)
raw: 057ff00000000200 ffffea0005169940 dead000000000002 ffff888017441a00
raw: ffff8881437fef00 0000000080100003 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 9098407805, free_ts 0
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x1a26/0x1ac0 mm/page_alloc.c:4328
 __alloc_pages+0x1df/0x4e0 mm/page_alloc.c:5614
 alloc_page_interleave+0x24/0x1e0 mm/mempolicy.c:2115
 alloc_slab_page+0x5d/0x160 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x87/0x2c0 mm/slub.c:1992
 ___slab_alloc+0xbc6/0x1220 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x1a0/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 call_usermodehelper_setup+0x8a/0x260 kernel/umh.c:366
 kobject_uevent_env+0x659/0x8a0 lib/kobject_uevent.c:629
 disk_uevent+0x278/0x450 block/genhd.c:352
 device_add_disk+0xd23/0x1020 block/genhd.c:537
 add_disk include/linux/blkdev.h:757 [inline]
 loop_add+0x6f2/0x9b0 drivers/block/loop.c:2071
 loop_init+0x173/0x226 drivers/block/loop.c:2263
 do_one_initcall+0x214/0x7a0 init/main.c:1298
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8881437fe500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881437fe580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8881437fe600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8881437fe680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8881437fe700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/04 19:32 linux-6.1.y 58485ff1a74f e565f08d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in pressure_write
* Struck through repros no longer work on HEAD.