syzbot


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

Status: auto-obsoleted due to no activity on 2023/12/21 16:19
Subsystems: kernel
[Documentation on labels]
Reported-by: syzbot+50ef815ba3bcce06d409@syzkaller.appspotmail.com
First crash: 395d, last: 395d
Discussions (2)
Title Replies (including bot) Last reply
Re: [syzbot] [kernel?] KASAN: slab-use-after-free Read in kill_orphaned_pgrp 1 (1) 2023/11/22 06:13
[syzbot] [kernel?] KASAN: slab-use-after-free Read in kill_orphaned_pgrp 0 (1) 2023/11/21 14:33
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in kill_orphaned_pgrp (2) kernel 5 156d 156d 0/28 auto-obsoleted due to no activity on 2024/08/16 18:03

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in task_pgrp include/linux/sched/signal.h:694 [inline]
BUG: KASAN: slab-use-after-free in kill_orphaned_pgrp+0x2e1/0x340 kernel/exit.c:376
Read of size 8 at addr ffff88802d78a6b8 by task vhost-16506/16518

CPU: 0 PID: 16518 Comm: vhost-16506 Not tainted 6.6.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:475
 kasan_report+0xda/0x110 mm/kasan/report.c:588
 task_pgrp include/linux/sched/signal.h:694 [inline]
 kill_orphaned_pgrp+0x2e1/0x340 kernel/exit.c:376
 exit_notify kernel/exit.c:737 [inline]
 do_exit+0x1cb5/0x2a20 kernel/exit.c:894
 vhost_task_fn+0x2e6/0x370 kernel/vhost_task.c:61
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
 </TASK>

Allocated by task 5090:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 __kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook mm/slab.h:762 [inline]
 slab_alloc_node mm/slub.c:3478 [inline]
 kmem_cache_alloc_node+0x185/0x3f0 mm/slub.c:3523
 alloc_task_struct_node kernel/fork.c:173 [inline]
 dup_task_struct kernel/fork.c:1110 [inline]
 copy_process+0x41c/0x7400 kernel/fork.c:2327
 kernel_clone+0xfd/0x930 kernel/fork.c:2909
 __do_sys_clone+0xba/0x100 kernel/fork.c:3052
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 42:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 kasan_set_track+0x25/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:164 [inline]
 slab_free_hook mm/slub.c:1800 [inline]
 slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
 slab_free mm/slub.c:3809 [inline]
 kmem_cache_free+0xf0/0x480 mm/slub.c:3831
 put_task_struct include/linux/sched/task.h:136 [inline]
 put_task_struct include/linux/sched/task.h:123 [inline]
 delayed_put_task_struct+0x246/0x2c0 kernel/exit.c:226
 rcu_do_batch kernel/rcu/tree.c:2139 [inline]
 rcu_core+0x7fb/0x1bb0 kernel/rcu/tree.c:2403
 __do_softirq+0x218/0x965 kernel/softirq.c:553

Last potentially related work creation:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
 put_task_struct_rcu_user kernel/exit.c:232 [inline]
 put_task_struct_rcu_user+0x87/0xc0 kernel/exit.c:229
 release_task+0xf0a/0x1b90 kernel/exit.c:282
 de_thread fs/exec.c:1158 [inline]
 begin_new_exec+0x226c/0x3110 fs/exec.c:1264
 load_elf_binary+0x8ec/0x5c40 fs/binfmt_elf.c:1001
 search_binary_handler fs/exec.c:1739 [inline]
 exec_binprm fs/exec.c:1781 [inline]
 bprm_execve fs/exec.c:1856 [inline]
 bprm_execve+0x80a/0x1a50 fs/exec.c:1812
 do_execveat_common.isra.0+0x5d3/0x740 fs/exec.c:1964
 do_execve fs/exec.c:2038 [inline]
 __do_sys_execve fs/exec.c:2114 [inline]
 __se_sys_execve fs/exec.c:2109 [inline]
 __x64_sys_execve+0x8c/0xb0 fs/exec.c:2109
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
 kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492
 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
 put_task_struct_rcu_user kernel/exit.c:232 [inline]
 put_task_struct_rcu_user+0x87/0xc0 kernel/exit.c:229
 context_switch kernel/sched/core.c:5385 [inline]
 __schedule+0xee9/0x59f0 kernel/sched/core.c:6695
 preempt_schedule_irq+0x52/0x90 kernel/sched/core.c:7007
 irqentry_exit+0x35/0x80 kernel/entry/common.c:432
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645

The buggy address belongs to the object at ffff88802d789dc0
 which belongs to the cache task_struct of size 7360
The buggy address is located 2296 bytes inside of
 freed 7360-byte region [ffff88802d789dc0, ffff88802d78ba80)

The buggy address belongs to the physical page:
page:ffffea0000b5e200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2d788
head:ffffea0000b5e200 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff888075f26101
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888014e49500 ffffea0001e00e00 dead000000000002
raw: 0000000000000000 0000000000040004 00000001ffffffff ffff888075f26101
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5278, tgid 5278 (syz-executor.3), ts 190312746205, free_ts 190291479937
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
 prep_new_page mm/page_alloc.c:1543 [inline]
 get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298
 alloc_slab_page mm/slub.c:1870 [inline]
 allocate_slab+0x251/0x380 mm/slub.c:2017
 new_slab mm/slub.c:2070 [inline]
 ___slab_alloc+0x8be/0x1570 mm/slub.c:3223
 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
 __slab_alloc_node mm/slub.c:3375 [inline]
 slab_alloc_node mm/slub.c:3468 [inline]
 kmem_cache_alloc_node+0x137/0x3f0 mm/slub.c:3523
 alloc_task_struct_node kernel/fork.c:173 [inline]
 dup_task_struct kernel/fork.c:1110 [inline]
 copy_process+0x41c/0x7400 kernel/fork.c:2327
 kernel_clone+0xfd/0x930 kernel/fork.c:2909
 __do_sys_clone3+0x1f1/0x260 kernel/fork.c:3210
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1136 [inline]
 free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
 __folio_put+0xeb/0x110 mm/swap.c:127
 folio_put include/linux/mm.h:1475 [inline]
 put_page include/linux/mm.h:1544 [inline]
 do_exit+0x2332/0x2a20 kernel/exit.c:913
 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024
 get_signal+0x23d1/0x27b0 kernel/signal.c:2892
 arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:309
 exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
 exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296
 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88802d78a580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802d78a600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802d78a680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff88802d78a700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802d78a780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/09/12 16:18 upstream 0bb80ecc33a8 59da8366 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in kill_orphaned_pgrp
* Struck through repros no longer work on HEAD.