syzbot


KASAN: slab-use-after-free Read in filter_chain

Status: auto-obsoleted due to no activity on 2024/11/22 10:45
Subsystems: perf trace
[Documentation on labels]
Reported-by: syzbot+772df6edd4e13e9e9bc5@syzkaller.appspotmail.com
First crash: 149d, last: 87d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [perf?] KASAN: slab-use-after-free Read in filter_chain 0 (1) 2024/07/15 18:52

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in consumer_filter kernel/events/uprobes.c:869 [inline]
BUG: KASAN: slab-use-after-free in filter_chain+0xf6/0x110 kernel/events/uprobes.c:880
Read of size 8 at addr ffff888023a65530 by task syz.4.1628/9987

CPU: 0 UID: 0 PID: 9987 Comm: syz.4.1628 Not tainted 6.11.0-rc3-syzkaller-00279-ge5fa841af679 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report+0xd9/0x110 mm/kasan/report.c:601
 consumer_filter kernel/events/uprobes.c:869 [inline]
 filter_chain+0xf6/0x110 kernel/events/uprobes.c:880
 uprobe_mmap+0x46b/0x1240 kernel/events/uprobes.c:1387
 mmap_region+0x1228/0x2760 mm/mmap.c:3058
 do_mmap+0xbfb/0xfb0 mm/mmap.c:1468
 vm_mmap_pgoff+0x1ba/0x360 mm/util.c:588
 ksys_mmap_pgoff+0x332/0x5d0 mm/mmap.c:1514
 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:86 [inline]
 __se_sys_mmap arch/x86/kernel/sys_x86_64.c:79 [inline]
 __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:79
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7714579e79
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:00007f771535b038 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f7714715f80 RCX: 00007f7714579e79
RDX: 0000000000000001 RSI: 0000000000400000 RDI: 0000000020000000
RBP: 00007f77145e7916 R08: 0000000000000004 R09: 0000000000000000
R10: 0000000000010012 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7714715f80 R15: 00007fffc982e0c8
 </TASK>

Allocated by task 9612:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kmalloc_noprof include/linux/slab.h:681 [inline]
 kzalloc_noprof include/linux/slab.h:807 [inline]
 percpu_ref_init+0xd9/0x400 lib/percpu-refcount.c:76
 ioctx_alloc+0x2d2/0x1fd0 fs/aio.c:782
 __do_sys_io_setup fs/aio.c:1399 [inline]
 __se_sys_io_setup fs/aio.c:1382 [inline]
 __x64_sys_io_setup+0xc9/0x210 fs/aio.c:1382
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5353:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object+0xf7/0x160 mm/kasan/common.c:240
 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2252 [inline]
 slab_free mm/slub.c:4473 [inline]
 kfree+0x12a/0x3b0 mm/slub.c:4594
 percpu_ref_exit+0xfb/0x150 lib/percpu-refcount.c:146
 free_ioctx+0x56/0xa0 fs/aio.c:625
 process_one_work+0x9c5/0x1b40 kernel/workqueue.c:3231
 process_scheduled_works kernel/workqueue.c:3312 [inline]
 worker_thread+0x6c8/0xf20 kernel/workqueue.c:3390
 kthread+0x2c1/0x3a0 kernel/kthread.c:389
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Last potentially related work creation:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 __kasan_record_aux_stack+0xba/0xd0 mm/kasan/generic.c:541
 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:3106
 call_rcu_hurry include/linux/rcupdate.h:113 [inline]
 __percpu_ref_switch_to_atomic lib/percpu-refcount.c:233 [inline]
 __percpu_ref_switch_mode+0x3b7/0x900 lib/percpu-refcount.c:281
 percpu_ref_kill_and_confirm+0x8c/0x180 lib/percpu-refcount.c:395
 percpu_ref_kill include/linux/percpu-refcount.h:149 [inline]
 kill_ioctx+0x1d4/0x2a0 fs/aio.c:880
 exit_aio+0x1b5/0x360 fs/aio.c:922
 __mmput+0x81/0x480 kernel/fork.c:1342
 mmput+0x62/0x70 kernel/fork.c:1367
 exit_mm kernel/exit.c:571 [inline]
 do_exit+0x9bf/0x2bb0 kernel/exit.c:869
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1031
 __do_sys_exit_group kernel/exit.c:1042 [inline]
 __se_sys_exit_group kernel/exit.c:1040 [inline]
 __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1040
 x64_sys_call+0x14a9/0x16a0 arch/x86/include/generated/asm/syscalls_64.h:232
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888023a65500
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 48 bytes inside of
 freed 64-byte region [ffff888023a65500, ffff888023a65540)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888023a65500 pfn:0x23a65
flags: 0xfff00000000200(workingset|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xfdffffff(slab)
raw: 00fff00000000200 ffff8880158418c0 ffffea0000b20250 ffffea0000b19990
raw: ffff888023a65500 0000000000200014 00000001fdffffff 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 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 4673, tgid 4673 (udevadm), ts 29626237021, free_ts 29626124965
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1493
 prep_new_page mm/page_alloc.c:1501 [inline]
 get_page_from_freelist+0x1351/0x2e50 mm/page_alloc.c:3442
 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4700
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x4e/0xf0 mm/slub.c:2321
 allocate_slab mm/slub.c:2484 [inline]
 new_slab+0x84/0x260 mm/slub.c:2537
 ___slab_alloc+0xdac/0x1870 mm/slub.c:3723
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3813
 __slab_alloc_node mm/slub.c:3866 [inline]
 slab_alloc_node mm/slub.c:4025 [inline]
 __do_kmalloc_node mm/slub.c:4157 [inline]
 __kmalloc_noprof+0x367/0x400 mm/slub.c:4170
 kmalloc_noprof include/linux/slab.h:685 [inline]
 kzalloc_noprof include/linux/slab.h:807 [inline]
 tomoyo_encode2+0x100/0x3e0 security/tomoyo/realpath.c:45
 tomoyo_encode+0x29/0x50 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x19d/0x720 security/tomoyo/realpath.c:283
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x2a7/0x3b0 security/tomoyo/file.c:771
 tomoyo_file_open+0x71/0x90 security/tomoyo/tomoyo.c:334
 security_file_open+0x78/0x8b0 security/security.c:2988
 do_dentry_open+0x5c7/0x15f0 fs/open.c:946
 vfs_open+0x82/0x3f0 fs/open.c:1089
page last free pid 4673 tgid 4673 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1094 [inline]
 free_unref_page+0x64a/0xe40 mm/page_alloc.c:2612
 selinux_genfs_get_sid security/selinux/hooks.c:1343 [inline]
 inode_doinit_with_dentry+0xac4/0x12c0 security/selinux/hooks.c:1541
 selinux_d_instantiate+0x26/0x30 security/selinux/hooks.c:6350
 security_d_instantiate+0x57/0xf0 security/security.c:3942
 d_splice_alias+0x94/0xdf0 fs/dcache.c:2982
 kernfs_iop_lookup+0x286/0x330 fs/kernfs/dir.c:1229
 lookup_open.isra.0+0x928/0x13c0 fs/namei.c:3556
 open_last_lookups fs/namei.c:3647 [inline]
 path_openat+0xa3b/0x2d20 fs/namei.c:3883
 do_filp_open+0x1dc/0x430 fs/namei.c:3913
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1416
 do_sys_open fs/open.c:1431 [inline]
 __do_sys_openat fs/open.c:1447 [inline]
 __se_sys_openat fs/open.c:1442 [inline]
 __x64_sys_openat+0x175/0x210 fs/open.c:1442
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888023a65400: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888023a65480: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
>ffff888023a65500: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                                     ^
 ffff888023a65580: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
 ffff888023a65600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/17 14:14 upstream e5fa841af679 dbc93b08 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in filter_chain
2024/08/08 06:47 upstream 6a0e38264012 de12cf65 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in filter_chain
2024/07/30 00:30 upstream dc1c8034e31b 5187fc86 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in filter_chain
2024/07/28 03:30 upstream 6342649c33d2 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in filter_chain
2024/07/21 06:17 upstream 2c9b3512402e b88348e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in filter_chain
2024/09/11 19:44 upstream 7c6a3a65ace7 ede7a22c .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in filter_chain
2024/09/11 00:17 upstream 8d8d276ba2fb 8ab55d0e .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in filter_chain
2024/07/13 18:13 upstream 528dd46d0fc3 eaeb5c15 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in filter_chain
2024/09/11 12:26 upstream 8d8d276ba2fb ede7a22c .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in filter_chain
2024/07/11 21:20 upstream 9d9a2f29aefd 3cf1187a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in filter_chain
2024/07/11 14:17 upstream 9d9a2f29aefd 6ca1eb5a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in filter_chain
2024/07/17 15:40 upstream 51835949dda3 03114f55 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-out-of-bounds Read in filter_chain
2024/09/10 12:20 upstream bc83b4d1f086 e1ac59f4 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-out-of-bounds Read in filter_chain
* Struck through repros no longer work on HEAD.