[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANX2M5YiZBXU3L6iwnaLs-HHJXRvrxM8mhPDiMDF9Y9sAvOHUA@mail.gmail.com>
Date: Wed, 20 Jul 2022 18:41:31 -0700
From: Dipanjan Das <mail.dipanjan.das@...il.com>
To: axboe@...nel.dk, asml.silence@...il.com, io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: syzkaller@...glegroups.com, fleischermarius@...glemail.com,
its.priyanka.bose@...il.com
Subject: KASAN: use-after-free Read in __io_remove_buffers
Hi,
We would like to report the following bug which has been found by our
modified version of syzkaller.
======================================================
description: KASAN: use-after-free Read in __io_remove_buffers
affected file: fs/io_uring.c
kernel version: 5.19-rc6
kernel commit: 32346491ddf24599decca06190ebca03ff9de7f8
git tree: upstream
kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=cd73026ceaed1402
crash reproducer: attached
======================================================
Crash log:
======================================================
BUG: KASAN: use-after-free in __io_remove_buffers.isra.0+0x401/0x530
fs/io_uring.c:5540
Read of size 2 at addr ffff88812e562012 by task kworker/u4:9/3708
CPU: 0 PID: 3708 Comm: kworker/u4:9 Tainted: G OE
5.19.0-rc6-g2eae0556bb9d #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Workqueue: events_unbound io_ring_exit_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:313 [inline]
print_report.cold+0xe5/0x659 mm/kasan/report.c:429
kasan_report+0x8a/0x1b0 mm/kasan/report.c:491
__io_remove_buffers.isra.0+0x401/0x530 fs/io_uring.c:5540
io_destroy_buffers fs/io_uring.c:11077 [inline]
io_ring_ctx_free fs/io_uring.c:11159 [inline]
io_ring_exit_work+0x9a2/0xf4b fs/io_uring.c:11338
process_one_work+0x9cc/0x1650 kernel/workqueue.c:2289
worker_thread+0x623/0x1070 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
</TASK>
Allocated by task 10568:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:441 [inline]
____kasan_kmalloc mm/kasan/common.c:526 [inline]
____kasan_kmalloc mm/kasan/common.c:479 [inline]
__kasan_kmalloc+0xb5/0xe0 mm/kasan/common.c:535
kasan_kmalloc include/linux/kasan.h:234 [inline]
__kmalloc+0x1c9/0x4c0 mm/slub.c:4446
kcalloc include/linux/slab.h:671 [inline]
io_init_bl_list.isra.0+0x24/0x102 fs/io_uring.c:5703
io_register_pbuf_ring fs/io_uring.c:12955 [inline]
__io_uring_register.cold+0xd/0x10b5 fs/io_uring.c:13151
__do_sys_io_uring_register fs/io_uring.c:13187 [inline]
__se_sys_io_uring_register fs/io_uring.c:13167 [inline]
__x64_sys_io_uring_register+0x2f2/0x650 fs/io_uring.c:13167
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+0x46/0xb0
Freed by task 10568:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39
kasan_set_track+0x21/0x30 mm/kasan/common.c:46
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:378
____kasan_slab_free mm/kasan/common.c:371 [inline]
____kasan_slab_free mm/kasan/common.c:329 [inline]
__kasan_slab_free+0x12b/0x1a0 mm/kasan/common.c:379
kasan_slab_free include/linux/kasan.h:200 [inline]
slab_free_hook mm/slub.c:1754 [inline]
slab_free_freelist_hook mm/slub.c:1780 [inline]
slab_free mm/slub.c:3536 [inline]
kfree+0xec/0x4b0 mm/slub.c:4584
io_register_pbuf_ring fs/io_uring.c:12975 [inline]
__io_uring_register+0x16aa/0x19d0 fs/io_uring.c:13151
__do_sys_io_uring_register fs/io_uring.c:13187 [inline]
__se_sys_io_uring_register fs/io_uring.c:13167 [inline]
__x64_sys_io_uring_register+0x2f2/0x650 fs/io_uring.c:13167
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+0x46/0xb0
Last potentially related work creation:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39
__kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:356
call_rcu kernel/rcu/tree.c:3126 [inline]
call_rcu+0x99/0x740 kernel/rcu/tree.c:3101
netlink_release+0xe42/0x1cb0 net/netlink/af_netlink.c:815
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x18/0x20 net/socket.c:1365
__fput+0x277/0x9d0 fs/file_table.c:317
task_work_run+0xe0/0x1a0 kernel/task_work.c:177
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:169 [inline]
exit_to_user_mode_prepare+0x253/0x260 kernel/entry/common.c:201
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x46/0xb0
Second to last potentially related work creation:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39
__kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:356
call_rcu kernel/rcu/tree.c:3126 [inline]
call_rcu+0x99/0x740 kernel/rcu/tree.c:3101
netlink_release+0xe42/0x1cb0 net/netlink/af_netlink.c:815
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x18/0x20 net/socket.c:1365
__fput+0x277/0x9d0 fs/file_table.c:317
task_work_run+0xe0/0x1a0 kernel/task_work.c:177
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xb1e/0x2dd0 kernel/exit.c:797
do_group_exit+0xd2/0x2f0 kernel/exit.c:927
get_signal+0x2842/0x2870 kernel/signal.c:2857
arch_do_signal_or_restart+0x82/0x2270 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop kernel/entry/common.c:166 [inline]
exit_to_user_mode_prepare+0x174/0x260 kernel/entry/common.c:201
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x46/0xb0
The buggy address belongs to the object at ffff88812e562000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 18 bytes inside of
2048-byte region [ffff88812e562000, ffff88812e562800)
The buggy address belongs to the physical page:
page:ffffea0004b95800 refcount:1 mapcount:0 mapping:0000000000000000
index:0x0 pfn:0x12e560
head:ffffea0004b95800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x17ff00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 017ff00000010200 ffffea0005da9600 dead000000000002 ffff888100042000
raw: 0000000000000000 0000000080080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask
0xd28c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC),
pid 6706, tgid 6706 (syz-executor.4), ts 116920478716, free_ts 0
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook mm/page_alloc.c:2449 [inline]
prep_new_page+0x297/0x330 mm/page_alloc.c:2456
get_page_from_freelist+0x2142/0x3c80 mm/page_alloc.c:4198
__alloc_pages+0x321/0x710 mm/page_alloc.c:5426
alloc_pages+0x119/0x250 mm/mempolicy.c:2272
alloc_slab_page mm/slub.c:1824 [inline]
allocate_slab mm/slub.c:1969 [inline]
new_slab+0x2a9/0x3f0 mm/slub.c:2029
___slab_alloc+0xd5a/0x1140 mm/slub.c:3031
__slab_alloc.isra.0+0x4d/0xa0 mm/slub.c:3118
slab_alloc_node mm/slub.c:3209 [inline]
__kmalloc_node_track_caller+0x321/0x440 mm/slub.c:4979
kmalloc_reserve+0x32/0xd0 net/core/skbuff.c:354
pskb_expand_head+0x148/0x1060 net/core/skbuff.c:1695
netlink_trim+0x1ea/0x240 net/netlink/af_netlink.c:1301
netlink_broadcast+0x5b/0xd00 net/netlink/af_netlink.c:1497
nlmsg_multicast include/net/netlink.h:1033 [inline]
nlmsg_notify+0x8f/0x280 net/netlink/af_netlink.c:2544
rtnl_notify net/core/rtnetlink.c:767 [inline]
rtmsg_ifinfo_send net/core/rtnetlink.c:3928 [inline]
rtmsg_ifinfo_event.part.0+0xb6/0xe0 net/core/rtnetlink.c:3943
rtmsg_ifinfo_event net/core/rtnetlink.c:6147 [inline]
rtnetlink_event+0x11e/0x150 net/core/rtnetlink.c:6140
notifier_call_chain+0xb5/0x200 kernel/notifier.c:87
page_owner free stack trace missing
Memory state around the buggy address:
ffff88812e561f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88812e561f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88812e562000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88812e562080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88812e562100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
--
Thanks and Regards,
Dipanjan
View attachment "repro.c" of type "text/x-csrc" (10067 bytes)
Download attachment "repro.syz" of type "application/octet-stream" (426 bytes)
Powered by blists - more mailing lists