lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <abe46bc0-d4a7-4076-bed8-c48e0267ebed@redhat.com>
Date: Wed, 25 Dec 2024 16:11:19 -0500
From: Waiman Long <llong@...hat.com>
To: Kun Hu <huk23@...udan.edu.cn>, peterz@...radead.org, mingo@...hat.com,
 will@...nel.org, boqun.feng@...il.com
Cc: linux-kernel@...r.kernel.org,
 "jjtan24@...udan.edu.cn" <jjtan24@...udan.edu.cn>,
 Jens Axboe <axboe@...nel.dk>, Pavel Begunkov <asml.silence@...il.com>,
 io-uring@...r.kernel.org
Subject: Re: Bug: slab-use-after-free Read in try_to_wake_up

On 12/24/24 7:28 AM, Kun Hu wrote:
> Hello,
>
> When using fuzzer tool to fuzz the latest Linux kernel, the following crash
> was triggered.
>
> HEAD commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
> git tree: upstream
> Console output:https://drive.google.com/file/d/11IXj9a4uRbOaqIK90F2px6nLiHhJ04rw/view?usp=sharing
> Kernel config: https://drive.google.com/file/d/1RhT5dFTs6Vx1U71PbpenN7TPtnPoa3NI/view?usp=sharing
> C reproducer: https://drive.google.com/file/d/1BP2d5rfb4XBuq0njxKnS6d3AoysIiT61/view?usp=sharing
> Syzlang reproducer: https://drive.google.com/file/d/1lTQrXRQfndtigBiKBxelQeHszr2dzbLp/view?usp=sharing
> Similar report: https://lore.kernel.org/lkml/CALcu4rZOs3sbXBWARhjM6d8UngPUF3bU1CPmSZBugUpgaP_0WA@mail.gmail.com/T/
>
>
> This bug seems to have been reported and fixed in the old kernel, which seems to be a regression issue? If you fix this issue, please add the following tag to the commit:
> Reported-by: Kun Hu <huk23@...udan.edu.cn>
>
>
> ==================================================================
> BUG: KASAN: slab-use-after-free in __lock_acquire+0x370b/0x4a10 kernel/locking/lockdep.c:5089
> Read of size 8 at addr ff1100000289acb8 by task syz.6.1904/11159
>
> CPU: 1 UID: 0 PID: 11159 Comm: syz.6.1904 Not tainted 6.13.0-rc3 #3
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
> Call Trace:
> <TASK>
> __dump_stack lib/dump_stack.c:94 [inline]
> dump_stack_lvl+0x116/0x1b0 lib/dump_stack.c:120
> print_address_description mm/kasan/report.c:378 [inline]
> print_report+0xcf/0x5f0 mm/kasan/report.c:489
> kasan_report+0x93/0xc0 mm/kasan/report.c:602
> __lock_acquire+0x370b/0x4a10 kernel/locking/lockdep.c:5089
> lock_acquire kernel/locking/lockdep.c:5849 [inline]
> lock_acquire+0x1b1/0x580 kernel/locking/lockdep.c:5814
> __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
> _raw_spin_lock_irqsave+0x3d/0x60 kernel/locking/spinlock.c:162
> class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:551 [inline]
> try_to_wake_up+0xb5/0x23c0 kernel/sched/core.c:4205
> io_sq_thread_park+0xac/0xe0 io_uring/sqpoll.c:55
> io_sq_thread_finish+0x6b/0x310 io_uring/sqpoll.c:96
> io_sq_offload_create+0x162/0x11d0 io_uring/sqpoll.c:497
> io_uring_create io_uring/io_uring.c:3724 [inline]
> io_uring_setup+0x1728/0x3230 io_uring/io_uring.c:3806
> __do_sys_io_uring_setup io_uring/io_uring.c:3833 [inline]
> __se_sys_io_uring_setup io_uring/io_uring.c:3827 [inline]
> __x64_sys_io_uring_setup+0x94/0x140 io_uring/io_uring.c:3827
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xc3/0x1d0 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7fa4396a071d
> Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 b0 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007fa4382f3ba8 EFLAGS: 00000246 ORIG_RAX: 00000000000001a9
> RAX: ffffffffffffffda RBX: 00007fa439862f80 RCX: 00007fa4396a071d
> RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000002616
> RBP: 00007fa4382f3c00 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000015
> R13: 00007fa439862f8c R14: 00007fa439863018 R15: 00007fa4382f3d40
> </TASK>

This is not caused by a locking bug. The freed structure is a 
task_struct which is passed by io_sq_thread() to try_to_wake_up(). So 
the culprit is probably in the io_uring code. cc'ing the io_uring 
developers for further review.

Cheers,
Longman

> Allocated by task 11159:
> kasan_save_stack+0x24/0x50 mm/kasan/common.c:47
> kasan_save_track+0x14/0x30 mm/kasan/common.c:68
> unpoison_slab_object mm/kasan/common.c:319 [inline]
> __kasan_slab_alloc+0x87/0x90 mm/kasan/common.c:345
> kasan_slab_alloc include/linux/kasan.h:250 [inline]
> slab_post_alloc_hook mm/slub.c:4119 [inline]
> slab_alloc_node mm/slub.c:4168 [inline]
> kmem_cache_alloc_node_noprof+0x14a/0x430 mm/slub.c:4220
> alloc_task_struct_node kernel/fork.c:180 [inline]
> dup_task_struct kernel/fork.c:1113 [inline]
> copy_process+0x487/0x7500 kernel/fork.c:2225
> create_io_thread+0xac/0xf0 kernel/fork.c:2755
> io_sq_offload_create+0xc62/0x11d0 io_uring/sqpoll.c:476
> io_uring_create io_uring/io_uring.c:3724 [inline]
> io_uring_setup+0x1728/0x3230 io_uring/io_uring.c:3806
> __do_sys_io_uring_setup io_uring/io_uring.c:3833 [inline]
> __se_sys_io_uring_setup io_uring/io_uring.c:3827 [inline]
> __x64_sys_io_uring_setup+0x94/0x140 io_uring/io_uring.c:3827
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xc3/0x1d0 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Freed by task 24:
> kasan_save_stack+0x24/0x50 mm/kasan/common.c:47
> kasan_save_track+0x14/0x30 mm/kasan/common.c:68
> kasan_save_free_info+0x3a/0x60 mm/kasan/generic.c:582
> poison_slab_object mm/kasan/common.c:247 [inline]
> __kasan_slab_free+0x54/0x70 mm/kasan/common.c:264
> kasan_slab_free include/linux/kasan.h:233 [inline]
> slab_free_hook mm/slub.c:2353 [inline]
> slab_free mm/slub.c:4613 [inline]
> kmem_cache_free+0x126/0x4d0 mm/slub.c:4715
> put_task_struct include/linux/sched/task.h:144 [inline]
> put_task_struct include/linux/sched/task.h:131 [inline]
> delayed_put_task_struct+0x229/0x300 kernel/exit.c:227
> rcu_do_batch kernel/rcu/tree.c:2567 [inline]
> rcu_core+0x7cb/0x16c0 kernel/rcu/tree.c:2823
> handle_softirqs+0x1ad/0x870 kernel/softirq.c:561
> run_ksoftirqd kernel/softirq.c:950 [inline]
> run_ksoftirqd+0x3a/0x60 kernel/softirq.c:942
> smpboot_thread_fn+0x669/0xa80 kernel/smpboot.c:164
> kthread+0x345/0x450 kernel/kthread.c:389
> ret_from_fork+0x48/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+0x24/0x50 mm/kasan/common.c:47
> __kasan_record_aux_stack+0xa6/0xc0 mm/kasan/generic.c:544
> __call_rcu_common.constprop.0+0x99/0x790 kernel/rcu/tree.c:3086
> put_task_struct_rcu_user+0x75/0xc0 kernel/exit.c:233
> finish_task_switch+0x4d2/0x720 kernel/sched/core.c:5278
> context_switch kernel/sched/core.c:5372 [inline]
> __schedule+0xe68/0x4120 kernel/sched/core.c:6756
> __schedule_loop kernel/sched/core.c:6833 [inline]
> schedule+0xd4/0x210 kernel/sched/core.c:6848
> do_nanosleep+0x20e/0x4e0 kernel/time/hrtimer.c:2079
> hrtimer_nanosleep+0x122/0x330 kernel/time/hrtimer.c:2126
> common_nsleep+0xaa/0xd0 kernel/time/posix-timers.c:1356
> __do_sys_clock_nanosleep kernel/time/posix-timers.c:1402 [inline]
> __se_sys_clock_nanosleep kernel/time/posix-timers.c:1379 [inline]
> __x64_sys_clock_nanosleep+0x33c/0x490 kernel/time/posix-timers.c:1379
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xc3/0x1d0 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> The buggy address belongs to the object at ff1100000289a340
> which belongs to the cache task_struct of size 8712
> The buggy address is located 2424 bytes inside of
> freed 8712-byte region [ff1100000289a340, ff1100000289c548)
>
> The buggy address belongs to the physical page:
> page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2898
> head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
> flags: 0x100000000000040(head|node=0|zone=1)
> page_type: f5(slab)
> raw: 0100000000000040 ff110000014cb040 ffd4000000549800 dead000000000004
> raw: 0000000000000000 0000000080030003 00000001f5000000 0000000000000000
> head: 0100000000000040 ff110000014cb040 ffd4000000549800 dead000000000004
> head: 0000000000000000 0000000080030003 00000001f5000000 0000000000000000
> head: 0100000000000003 ffd40000000a2601 ffffffffffffffff 0000000000000000
> head: ff11000000000008 0000000000000000 00000000ffffffff 0000000000000000
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
> ff1100000289ab80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ff1100000289ac00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ff1100000289ac80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ^
> ff1100000289ad00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ff1100000289ad80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
>
>
> ——————
> Thanks,
> Kun Hu
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ