* [syzbot] KASAN: use-after-free Write in io_queue_worker_create
@ 2021-12-06 6:43 syzbot
2021-12-06 17:28 ` Jens Axboe
2021-12-10 5:21 ` syzbot
0 siblings, 2 replies; 7+ messages in thread
From: syzbot @ 2021-12-06 6:43 UTC (permalink / raw)
To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 944207047ca4 Merge tag 'usb-5.16-rc4' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13ebd129b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=171728a464c05f2b
dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
Unfortunately, I don't have any reproducer for this issue yet.
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:86 [inline]
BUG: KASAN: use-after-free in clear_bit_unlock include/asm-generic/bitops/instrumented-lock.h:25 [inline]
BUG: KASAN: use-after-free in io_queue_worker_create+0x453/0x4e0 fs/io-wq.c:363
Write of size 8 at addr ffff888023e068d8 by task kworker/3:4/13798
CPU: 3 PID: 13798 Comm: kworker/3:4 Not tainted 5.16.0-rc3-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
Workqueue: events io_workqueue_create
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0x8d/0x2ed mm/kasan/report.c:247
__kasan_report mm/kasan/report.c:433 [inline]
kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
instrument_atomic_write include/linux/instrumented.h:86 [inline]
clear_bit_unlock include/asm-generic/bitops/instrumented-lock.h:25 [inline]
io_queue_worker_create+0x453/0x4e0 fs/io-wq.c:363
io_workqueue_create+0x9e/0xe0 fs/io-wq.c:780
process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
</TASK>
Allocated by task 5554:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
____kasan_kmalloc mm/kasan/common.c:513 [inline]
____kasan_kmalloc mm/kasan/common.c:472 [inline]
__kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:522
kasan_kmalloc include/linux/kasan.h:269 [inline]
kmem_cache_alloc_node_trace+0x208/0x5b0 mm/slab.c:3619
kmalloc_node include/linux/slab.h:608 [inline]
kzalloc_node include/linux/slab.h:735 [inline]
create_io_worker+0x108/0x630 fs/io-wq.c:792
io_wqe_create_worker fs/io-wq.c:300 [inline]
io_wqe_enqueue+0x692/0xbc0 fs/io-wq.c:924
io_queue_async_work+0x28b/0x5d0 fs/io_uring.c:1585
io_queue_sqe_arm_apoll+0xcf/0x1a0 fs/io_uring.c:7004
__io_queue_sqe fs/io_uring.c:7033 [inline]
io_queue_sqe fs/io_uring.c:7060 [inline]
io_submit_sqe fs/io_uring.c:7263 [inline]
io_submit_sqes+0x796a/0x8a20 fs/io_uring.c:7369
__do_sys_io_uring_enter+0xf6e/0x1f50 fs/io_uring.c:10070
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 5554:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
kasan_set_track+0x21/0x30 mm/kasan/common.c:46
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
____kasan_slab_free mm/kasan/common.c:366 [inline]
____kasan_slab_free mm/kasan/common.c:328 [inline]
__kasan_slab_free+0xd1/0x110 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:235 [inline]
__cache_free mm/slab.c:3445 [inline]
kfree+0x10d/0x2c0 mm/slab.c:3802
create_worker_cont+0x3fb/0x550 fs/io-wq.c:766
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
Last potentially related work creation:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
__kasan_record_aux_stack+0xb5/0xe0 mm/kasan/generic.c:348
task_work_add+0x3a/0x190 kernel/task_work.c:38
io_queue_worker_create+0x3ee/0x4e0 fs/io-wq.c:362
io_workqueue_create+0x9e/0xe0 fs/io-wq.c:780
process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
Second to last potentially related work creation:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
__kasan_record_aux_stack+0xb5/0xe0 mm/kasan/generic.c:348
insert_work+0x48/0x370 kernel/workqueue.c:1354
__queue_work+0x5ca/0xee0 kernel/workqueue.c:1520
queue_work_on+0xee/0x110 kernel/workqueue.c:1547
queue_work include/linux/workqueue.h:502 [inline]
schedule_work include/linux/workqueue.h:563 [inline]
create_worker_cont+0x44b/0x550 fs/io-wq.c:772
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff888023e06800
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff888023e06800, ffff888023e06a00)
The buggy address belongs to the page:
page:ffffea00008f8180 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x23e06
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00004f9bc8 ffffea000072de48 ffff888010c40600
raw: 0000000000000000 ffff888023e06000 0000000100000004 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 0x2c2220(__GFP_HIGH|__GFP_ATOMIC|__GFP_NOWARN|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_THISNODE), pid 10854, ts 2474866807743, free_ts 2469053292495
prep_new_page mm/page_alloc.c:2418 [inline]
get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4149
__alloc_pages_slowpath.constprop.0+0x2eb/0x20d0 mm/page_alloc.c:4914
__alloc_pages+0x412/0x500 mm/page_alloc.c:5382
__alloc_pages_node include/linux/gfp.h:570 [inline]
kmem_getpages mm/slab.c:1377 [inline]
cache_grow_begin+0x75/0x470 mm/slab.c:2593
cache_alloc_refill+0x27f/0x380 mm/slab.c:2965
____cache_alloc mm/slab.c:3048 [inline]
____cache_alloc mm/slab.c:3031 [inline]
slab_alloc_node mm/slab.c:3249 [inline]
kmem_cache_alloc_node_trace+0x49c/0x5b0 mm/slab.c:3617
__do_kmalloc_node mm/slab.c:3639 [inline]
__kmalloc_node_track_caller+0x38/0x60 mm/slab.c:3654
kmalloc_reserve net/core/skbuff.c:354 [inline]
__alloc_skb+0xde/0x340 net/core/skbuff.c:426
skb_copy+0x137/0x2f0 net/core/skbuff.c:1586
mac80211_hwsim_tx_frame_no_nl.isra.0+0xb17/0x1330 drivers/net/wireless/mac80211_hwsim.c:1565
mac80211_hwsim_tx+0x574/0x12e0 drivers/net/wireless/mac80211_hwsim.c:1669
drv_tx net/mac80211/driver-ops.h:35 [inline]
ieee80211_tx_frags+0x552/0x970 net/mac80211/tx.c:1714
__ieee80211_tx+0x145/0x4c0 net/mac80211/tx.c:1768
ieee80211_tx+0x325/0x420 net/mac80211/tx.c:1948
ieee80211_xmit+0x339/0x420 net/mac80211/tx.c:2040
__ieee80211_subif_start_xmit+0x7ce/0xdc0 net/mac80211/tx.c:4248
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1338 [inline]
free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1389
free_unref_page_prepare mm/page_alloc.c:3309 [inline]
free_unref_page+0x19/0x690 mm/page_alloc.c:3388
slab_destroy mm/slab.c:1627 [inline]
slabs_destroy+0x89/0xc0 mm/slab.c:1647
cache_flusharray mm/slab.c:3418 [inline]
___cache_free+0x4cc/0x610 mm/slab.c:3480
qlink_free mm/kasan/quarantine.c:146 [inline]
qlist_free_all+0x4e/0x110 mm/kasan/quarantine.c:165
kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:272
__kasan_slab_alloc+0x97/0xb0 mm/kasan/common.c:444
kasan_slab_alloc include/linux/kasan.h:259 [inline]
slab_post_alloc_hook mm/slab.h:519 [inline]
slab_alloc mm/slab.c:3323 [inline]
kmem_cache_alloc+0x1bc/0x560 mm/slab.c:3507
sock_alloc_inode+0x18/0x1c0 net/socket.c:303
alloc_inode+0x61/0x230 fs/inode.c:235
new_inode_pseudo+0x14/0xe0 fs/inode.c:944
sock_alloc+0x3c/0x260 net/socket.c:626
__sock_create+0xb9/0x790 net/socket.c:1428
sock_create net/socket.c:1515 [inline]
__sys_socket+0xef/0x200 net/socket.c:1557
__do_sys_socket net/socket.c:1566 [inline]
__se_sys_socket net/socket.c:1564 [inline]
__x64_sys_socket+0x6f/0xb0 net/socket.c:1564
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
Memory state around the buggy address:
ffff888023e06780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888023e06800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888023e06880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888023e06900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888023e06980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
---
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 [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-06 6:43 [syzbot] KASAN: use-after-free Write in io_queue_worker_create syzbot
@ 2021-12-06 17:28 ` Jens Axboe
2021-12-10 5:21 ` syzbot
1 sibling, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2021-12-06 17:28 UTC (permalink / raw)
To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs
On 12/5/21 11:43 PM, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 944207047ca4 Merge tag 'usb-5.16-rc4' of git://git.kernel...
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13ebd129b00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=171728a464c05f2b
> dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> ==================================================================
> BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:86 [inline]
> BUG: KASAN: use-after-free in clear_bit_unlock include/asm-generic/bitops/instrumented-lock.h:25 [inline]
> BUG: KASAN: use-after-free in io_queue_worker_create+0x453/0x4e0 fs/io-wq.c:363
> Write of size 8 at addr ffff888023e068d8 by task kworker/3:4/13798
Looks like a spurious clear that can race with the task_work already ran and
the worker got dropped. Both handlers do clear it, so I think we just need:
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 50cf9f92da36..35da9d90df76 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -359,10 +359,8 @@ static bool io_queue_worker_create(struct io_worker *worker,
init_task_work(&worker->create_work, func);
worker->create_index = acct->index;
- if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL)) {
- clear_bit_unlock(0, &worker->create_state);
+ if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL))
return true;
- }
clear_bit_unlock(0, &worker->create_state);
fail_release:
io_worker_release(worker);
--
Jens Axboe
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-06 6:43 [syzbot] KASAN: use-after-free Write in io_queue_worker_create syzbot
2021-12-06 17:28 ` Jens Axboe
@ 2021-12-10 5:21 ` syzbot
2021-12-10 5:26 ` Jens Axboe
1 sibling, 1 reply; 7+ messages in thread
From: syzbot @ 2021-12-10 5:21 UTC (permalink / raw)
To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs
syzbot has found a reproducer for the following issue on:
HEAD commit: c741e49150db Merge tag 'for-linus' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=125600bab00000
kernel config: https://syzkaller.appspot.com/x/.config?x=221ffc09e39ebbd1
dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1686906db00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1539a9b9b00000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:86 [inline]
BUG: KASAN: use-after-free in clear_bit_unlock include/asm-generic/bitops/instrumented-lock.h:25 [inline]
BUG: KASAN: use-after-free in io_queue_worker_create+0x453/0x4e0 fs/io-wq.c:363
Write of size 8 at addr ffff88806e6920d8 by task kworker/1:1/25
CPU: 1 PID: 25 Comm: kworker/1:1 Not tainted 5.16.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events io_workqueue_create
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247
__kasan_report mm/kasan/report.c:433 [inline]
kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
instrument_atomic_write include/linux/instrumented.h:86 [inline]
clear_bit_unlock include/asm-generic/bitops/instrumented-lock.h:25 [inline]
io_queue_worker_create+0x453/0x4e0 fs/io-wq.c:363
io_workqueue_create+0x9e/0xe0 fs/io-wq.c:780
process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
</TASK>
Allocated by task 4385:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
____kasan_kmalloc mm/kasan/common.c:513 [inline]
____kasan_kmalloc mm/kasan/common.c:472 [inline]
__kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:522
kmalloc_node include/linux/slab.h:608 [inline]
kzalloc_node include/linux/slab.h:735 [inline]
create_io_worker+0x108/0x630 fs/io-wq.c:792
create_worker_cb+0x202/0x270 fs/io-wq.c:329
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 4385:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
kasan_set_track+0x21/0x30 mm/kasan/common.c:46
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
____kasan_slab_free mm/kasan/common.c:366 [inline]
____kasan_slab_free mm/kasan/common.c:328 [inline]
__kasan_slab_free+0xff/0x130 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:1723 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1749
slab_free mm/slub.c:3513 [inline]
kfree+0xf6/0x560 mm/slub.c:4561
create_worker_cont+0x3fb/0x550 fs/io-wq.c:766
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
Last potentially related work creation:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
__kasan_record_aux_stack+0xf5/0x120 mm/kasan/generic.c:348
task_work_add+0x3a/0x190 kernel/task_work.c:38
io_queue_worker_create+0x3ee/0x4e0 fs/io-wq.c:362
io_workqueue_create+0x9e/0xe0 fs/io-wq.c:780
process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
Second to last potentially related work creation:
kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38
__kasan_record_aux_stack+0xf5/0x120 mm/kasan/generic.c:348
insert_work+0x48/0x370 kernel/workqueue.c:1354
__queue_work+0x5ca/0xee0 kernel/workqueue.c:1520
queue_work_on+0xee/0x110 kernel/workqueue.c:1547
queue_work include/linux/workqueue.h:502 [inline]
schedule_work include/linux/workqueue.h:563 [inline]
create_worker_cont+0x44b/0x550 fs/io-wq.c:772
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff88806e692000
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 216 bytes inside of
512-byte region [ffff88806e692000, ffff88806e692200)
The buggy address belongs to the page:
page:ffffea0001b9a400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6e690
head:ffffea0001b9a400 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c41c80
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4385, ts 49566988561, free_ts 10514971018
prep_new_page mm/page_alloc.c:2418 [inline]
get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4149
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5369
__alloc_pages_node include/linux/gfp.h:570 [inline]
alloc_slab_page mm/slub.c:1795 [inline]
allocate_slab mm/slub.c:1930 [inline]
new_slab+0xab/0x4a0 mm/slub.c:1993
___slab_alloc+0x918/0xfe0 mm/slub.c:3022
__slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109
slab_alloc_node mm/slub.c:3200 [inline]
kmem_cache_alloc_node_trace+0x116/0x310 mm/slub.c:3284
kmalloc_node include/linux/slab.h:608 [inline]
kzalloc_node include/linux/slab.h:735 [inline]
create_io_worker+0x108/0x630 fs/io-wq.c:792
create_worker_cb+0x202/0x270 fs/io-wq.c:329
task_work_run+0xdd/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:214 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x256/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1338 [inline]
free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1389
free_unref_page_prepare mm/page_alloc.c:3309 [inline]
free_unref_page+0x19/0x690 mm/page_alloc.c:3388
free_contig_range+0xa8/0xf0 mm/page_alloc.c:9271
destroy_args+0xa8/0x646 mm/debug_vm_pgtable.c:1016
debug_vm_pgtable+0x2984/0x2a16 mm/debug_vm_pgtable.c:1330
do_one_initcall+0x103/0x650 init/main.c:1297
do_initcall_level init/main.c:1370 [inline]
do_initcalls init/main.c:1386 [inline]
do_basic_setup init/main.c:1405 [inline]
kernel_init_freeable+0x6b1/0x73a init/main.c:1610
kernel_init+0x1a/0x1d0 init/main.c:1499
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
Memory state around the buggy address:
ffff88806e691f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88806e692000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806e692080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88806e692100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806e692180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-10 5:21 ` syzbot
@ 2021-12-10 5:26 ` Jens Axboe
2021-12-10 11:00 ` syzbot
0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2021-12-10 5:26 UTC (permalink / raw)
To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs
On 12/9/21 10:21 PM, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: c741e49150db Merge tag 'for-linus' of git://git.kernel.org..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=125600bab00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=221ffc09e39ebbd1
> dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1686906db00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1539a9b9b00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
#syz test git://git.kernel.dk/linux-block io_uring-5.16
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-10 5:26 ` Jens Axboe
@ 2021-12-10 11:00 ` syzbot
2021-12-10 15:33 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: syzbot @ 2021-12-10 11:00 UTC (permalink / raw)
To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
INFO: task hung in io_wq_put_and_exit
INFO: task syz-executor.2:8594 blocked for more than 143 seconds.
Not tainted 5.16.0-rc1-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor.2 state:D stack:26928 pid: 8594 ppid: 3894 flags:0x00024004
Call Trace:
<TASK>
context_switch kernel/sched/core.c:4972 [inline]
__schedule+0xa9a/0x4940 kernel/sched/core.c:6253
schedule+0xd2/0x260 kernel/sched/core.c:6326
schedule_timeout+0x1db/0x2a0 kernel/time/timer.c:1857
do_wait_for_common kernel/sched/completion.c:85 [inline]
__wait_for_common kernel/sched/completion.c:106 [inline]
wait_for_common kernel/sched/completion.c:117 [inline]
wait_for_completion+0x174/0x270 kernel/sched/completion.c:138
io_wq_exit_workers fs/io-wq.c:1222 [inline]
io_wq_put_and_exit+0x33a/0xb70 fs/io-wq.c:1257
io_uring_clean_tctx fs/io_uring.c:9803 [inline]
io_uring_cancel_generic+0x622/0x695 fs/io_uring.c:9886
io_uring_files_cancel include/linux/io_uring.h:16 [inline]
do_exit+0x60c/0x2b40 kernel/exit.c:787
do_group_exit+0x125/0x310 kernel/exit.c:929
get_signal+0x47d/0x2220 kernel/signal.c:2830
arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868
handle_signal_work kernel/entry/common.c:148 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207
__syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fe940cbfb49
RSP: 002b:00007fe940435218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007fe940dd2f68 RCX: 00007fe940cbfb49
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007fe940dd2f68
RBP: 00007fe940dd2f60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe940dd2f6c
R13: 00007ffc1b1af90f R14: 00007fe940435300 R15: 0000000000022000
</TASK>
Showing all locks held in the system:
1 lock held by khungtaskd/27:
#0: ffffffff8bb83a60 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6458
2 locks held by getty/3278:
#0: ffff888023517098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:252
#1: ffffc90002b962e8 (&ldata->atomic_read_lock){+.+.}-{3:3}, at: n_tty_read+0xcf0/0x1230 drivers/tty/n_tty.c:2113
2 locks held by kworker/u4:8/4544:
#0: ffff8880b9d39a98 (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x2b/0x120 kernel/sched/core.c:478
#1: ffffc900038bfdb0 ((work_completion)(&(&bat_priv->nc.work)->work)){+.+.}-{0:0}, at: process_one_work+0x8ca/0x1690 kernel/workqueue.c:2273
=============================================
NMI backtrace for cpu 0
CPU: 0 PID: 27 Comm: khungtaskd Not tainted 5.16.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
nmi_cpu_backtrace.cold+0x47/0x144 lib/nmi_backtrace.c:105
nmi_trigger_cpumask_backtrace+0x1ae/0x220 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:146 [inline]
check_hung_uninterruptible_tasks kernel/hung_task.c:210 [inline]
watchdog+0xc1d/0xf50 kernel/hung_task.c:295
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
</TASK>
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 PID: 4355 Comm: kworker/u4:7 Not tainted 5.16.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: phy12 ieee80211_iface_work
RIP: 0010:mark_lock+0x27/0x17b0 kernel/locking/lockdep.c:4566
Code: 00 00 90 41 57 41 56 41 55 41 54 41 89 d4 48 ba 00 00 00 00 00 fc ff df 55 53 48 81 ec 18 01 00 00 48 8d 5c 24 38 48 89 3c 24 <48> c7 44 24 38 b3 8a b5 41 48 c1 eb 03 48 c7 44 24 40 e0 66 37 8b
RSP: 0018:ffffc90002dbf380 EFLAGS: 00000082
RAX: 0000000000000004 RBX: ffffc90002dbf3b8 RCX: 1ffffffff1b228f1
RDX: dffffc0000000000 RSI: ffff88801d8fe160 RDI: ffff88801d8fd700
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000001
R10: ffffffff817e2bc8 R11: 0000000000000000 R12: 0000000000000002
R13: dffffc0000000000 R14: ffff88801d8fe160 R15: 000000000003d510
FS: 0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055de5437a600 CR3: 000000000b88e000 CR4: 0000000000350ee0
Call Trace:
<TASK>
mark_held_locks+0x9f/0xe0 kernel/locking/lockdep.c:4206
__trace_hardirqs_on_caller kernel/locking/lockdep.c:4224 [inline]
lockdep_hardirqs_on_prepare kernel/locking/lockdep.c:4292 [inline]
lockdep_hardirqs_on_prepare+0x135/0x400 kernel/locking/lockdep.c:4244
trace_hardirqs_on+0x5b/0x1c0 kernel/trace/trace_preemptirq.c:49
___slab_alloc+0xc41/0xfe0 mm/slub.c:2978
__slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109
slab_alloc_node mm/slub.c:3200 [inline]
slab_alloc mm/slub.c:3242 [inline]
__kmalloc+0x2fb/0x340 mm/slub.c:4419
kmalloc include/linux/slab.h:595 [inline]
kzalloc include/linux/slab.h:724 [inline]
cfg80211_inform_single_bss_frame_data+0x302/0xee0 net/wireless/scan.c:2397
cfg80211_inform_bss_frame_data+0xa7/0xb50 net/wireless/scan.c:2458
ieee80211_bss_info_update+0x35b/0xb30 net/mac80211/scan.c:190
ieee80211_rx_bss_info net/mac80211/ibss.c:1119 [inline]
ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1610 [inline]
ieee80211_ibss_rx_queued_mgmt+0x19cf/0x3130 net/mac80211/ibss.c:1639
ieee80211_iface_process_skb net/mac80211/iface.c:1466 [inline]
ieee80211_iface_work+0xa65/0xd00 net/mac80211/iface.c:1520
process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
kthread+0x405/0x4f0 kernel/kthread.c:327
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
</TASK>
----------------
Code disassembly (best guess):
0: 00 00 add %al,(%rax)
2: 90 nop
3: 41 57 push %r15
5: 41 56 push %r14
7: 41 55 push %r13
9: 41 54 push %r12
b: 41 89 d4 mov %edx,%r12d
e: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
15: fc ff df
18: 55 push %rbp
19: 53 push %rbx
1a: 48 81 ec 18 01 00 00 sub $0x118,%rsp
21: 48 8d 5c 24 38 lea 0x38(%rsp),%rbx
26: 48 89 3c 24 mov %rdi,(%rsp)
* 2a: 48 c7 44 24 38 b3 8a movq $0x41b58ab3,0x38(%rsp) <-- trapping instruction
31: b5 41
33: 48 c1 eb 03 shr $0x3,%rbx
37: 48 c7 44 24 40 e0 66 movq $0xffffffff8b3766e0,0x40(%rsp)
3e: 37 8b
Tested on:
commit: 02a3f9f3 io_uring: ensure task_work gets run as part o..
git tree: git://git.kernel.dk/linux-block io_uring-5.16
console output: https://syzkaller.appspot.com/x/log.txt?x=1037614db00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d3b8fd1977c1e73
dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-10 11:00 ` syzbot
@ 2021-12-10 15:33 ` Jens Axboe
2021-12-10 16:15 ` syzbot
0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2021-12-10 15:33 UTC (permalink / raw)
To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs
On 12/10/21 4:00 AM, syzbot wrote:
> Hello,
>
> syzbot has tested the proposed patch but the reproducer is still triggering an issue:
> INFO: task hung in io_wq_put_and_exit
>
> INFO: task syz-executor.2:8594 blocked for more than 143 seconds.
> Not tainted 5.16.0-rc1-syzkaller #0
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> task:syz-executor.2 state:D stack:26928 pid: 8594 ppid: 3894 flags:0x00024004
> Call Trace:
> <TASK>
> context_switch kernel/sched/core.c:4972 [inline]
> __schedule+0xa9a/0x4940 kernel/sched/core.c:6253
> schedule+0xd2/0x260 kernel/sched/core.c:6326
> schedule_timeout+0x1db/0x2a0 kernel/time/timer.c:1857
> do_wait_for_common kernel/sched/completion.c:85 [inline]
> __wait_for_common kernel/sched/completion.c:106 [inline]
> wait_for_common kernel/sched/completion.c:117 [inline]
> wait_for_completion+0x174/0x270 kernel/sched/completion.c:138
> io_wq_exit_workers fs/io-wq.c:1222 [inline]
> io_wq_put_and_exit+0x33a/0xb70 fs/io-wq.c:1257
> io_uring_clean_tctx fs/io_uring.c:9803 [inline]
> io_uring_cancel_generic+0x622/0x695 fs/io_uring.c:9886
> io_uring_files_cancel include/linux/io_uring.h:16 [inline]
> do_exit+0x60c/0x2b40 kernel/exit.c:787
> do_group_exit+0x125/0x310 kernel/exit.c:929
> get_signal+0x47d/0x2220 kernel/signal.c:2830
> arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868
> handle_signal_work kernel/entry/common.c:148 [inline]
> exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
> exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207
> __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
> syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
> do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
> entry_SYSCALL_64_after_hwframe+0x44/0xae
> RIP: 0033:0x7fe940cbfb49
> RSP: 002b:00007fe940435218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
> RAX: fffffffffffffe00 RBX: 00007fe940dd2f68 RCX: 00007fe940cbfb49
> RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007fe940dd2f68
> RBP: 00007fe940dd2f60 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe940dd2f6c
> R13: 00007ffc1b1af90f R14: 00007fe940435300 R15: 0000000000022000
> </TASK>
#syz test git://git.kernel.dk/linux-block io_uring-5.16
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [syzbot] KASAN: use-after-free Write in io_queue_worker_create
2021-12-10 15:33 ` Jens Axboe
@ 2021-12-10 16:15 ` syzbot
0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2021-12-10 16:15 UTC (permalink / raw)
To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: [email protected]
Tested on:
commit: 263568d1 io-wq: check for wq exit after adding new wor..
git tree: git://git.kernel.dk/linux-block io_uring-5.16
kernel config: https://syzkaller.appspot.com/x/.config?x=6c3ab72998e7f1a4
dashboard link: https://syzkaller.appspot.com/bug?extid=b60c982cb0efc5e05a47
compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-10 16:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-06 6:43 [syzbot] KASAN: use-after-free Write in io_queue_worker_create syzbot
2021-12-06 17:28 ` Jens Axboe
2021-12-10 5:21 ` syzbot
2021-12-10 5:26 ` Jens Axboe
2021-12-10 11:00 ` syzbot
2021-12-10 15:33 ` Jens Axboe
2021-12-10 16:15 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox