public inbox for [email protected]
 help / color / mirror / Atom feed
* [syzbot] KASAN: use-after-free Read in io_poll_check_events
@ 2022-02-19  9:20 syzbot
  2022-04-01  9:22 ` syzbot
  2022-04-01 12:26 ` syzbot
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2022-02-19  9:20 UTC (permalink / raw)
  To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    d567f5db412e Merge tag 'regulator-fix-v5.17-rc4' of git://..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=137545a4700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c252f01504189189
dashboard link: https://syzkaller.appspot.com/bug?extid=edb9c7738ba8cbdbf197
compiler:       Debian clang version 11.0.1-2, 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 io_poll_check_events+0x994/0x9a0 fs/io_uring.c:5516
Read of size 4 at addr ffff88802452ba2c by task kworker/1:21/2630

CPU: 1 PID: 2630 Comm: kworker/1:21 Not tainted 5.17.0-rc4-syzkaller-00002-gd567f5db412e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events io_fallback_req_func
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x65/0x3a0 mm/kasan/report.c:255
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report+0x19a/0x1f0 mm/kasan/report.c:459
 io_poll_check_events+0x994/0x9a0 fs/io_uring.c:5516
 io_apoll_task_func+0x4c/0xb10 fs/io_uring.c:5590
 io_fallback_req_func+0x118/0x1fd fs/io_uring.c:1400
 process_one_work+0x86c/0x1190 kernel/workqueue.c:2307
 worker_thread+0xab1/0x1300 kernel/workqueue.c:2454
 kthread+0x2a3/0x2d0 kernel/kthread.c:377
 ret_from_fork+0x1f/0x30
 </TASK>

Allocated by task 9351:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:469
 kasan_slab_alloc include/linux/kasan.h:260 [inline]
 slab_post_alloc_hook mm/slab.h:732 [inline]
 slab_alloc_node mm/slub.c:3230 [inline]
 kmem_cache_alloc_node+0x201/0x370 mm/slub.c:3266
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x52/0x9a0 kernel/fork.c:883
 copy_process+0x64a/0x5aa0 kernel/fork.c:1998
 kernel_clone+0x22a/0x7e0 kernel/fork.c:2555
 __do_sys_clone kernel/fork.c:2672 [inline]
 __se_sys_clone kernel/fork.c:2656 [inline]
 __x64_sys_clone+0x245/0x2b0 kernel/fork.c:2656
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 2630:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x126/0x180 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:236 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1754
 slab_free mm/slub.c:3509 [inline]
 kmem_cache_free+0xb6/0x1c0 mm/slub.c:3526
 __io_req_complete_post+0x25c/0x470 fs/io_uring.c:1960
 io_req_complete_post fs/io_uring.c:1972 [inline]
 io_req_complete_failed fs/io_uring.c:2003 [inline]
 io_apoll_task_func+0x226/0xb10 fs/io_uring.c:5602
 io_fallback_req_func+0x118/0x1fd fs/io_uring.c:1400
 process_one_work+0x86c/0x1190 kernel/workqueue.c:2307
 worker_thread+0xab1/0x1300 kernel/workqueue.c:2454
 kthread+0x2a3/0x2d0 kernel/kthread.c:377
 ret_from_fork+0x1f/0x30

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3026 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3106
 context_switch kernel/sched/core.c:4990 [inline]
 __schedule+0x92e/0x1080 kernel/sched/core.c:6296
 preempt_schedule_common kernel/sched/core.c:6462 [inline]
 preempt_schedule+0x14d/0x190 kernel/sched/core.c:6487
 preempt_schedule_thunk+0x16/0x18
 __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:160 [inline]
 _raw_spin_unlock_irq+0x3c/0x40 kernel/locking/spinlock.c:202
 spin_unlock_irq include/linux/spinlock.h:399 [inline]
 do_group_exit+0x29f/0x2b0 kernel/exit.c:932
 __do_sys_exit_group+0x13/0x20 kernel/exit.c:946
 __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:944
 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:944
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3026 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3106
 put_task_struct_rcu_user kernel/exit.c:180 [inline]
 release_task+0x133b/0x15d0 kernel/exit.c:226
 wait_task_zombie kernel/exit.c:1121 [inline]
 wait_consider_task+0x1995/0x3020 kernel/exit.c:1348
 do_wait_thread kernel/exit.c:1411 [inline]
 do_wait+0x291/0x9d0 kernel/exit.c:1528
 kernel_wait4+0x2a3/0x3c0 kernel/exit.c:1691
 __do_sys_wait4 kernel/exit.c:1719 [inline]
 __se_sys_wait4 kernel/exit.c:1715 [inline]
 __x64_sys_wait4+0x130/0x1e0 kernel/exit.c:1715
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

The buggy address belongs to the object at ffff88802452ba00
 which belongs to the cache task_struct of size 7168
The buggy address is located 44 bytes inside of
 7168-byte region [ffff88802452ba00, ffff88802452d600)
The buggy address belongs to the page:
page:ffffea0000914a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888024528000 pfn:0x24528
head:ffffea0000914a00 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88801b05ff01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00008c1408 ffffea0001f56408 ffff888140006280
raw: ffff888024528000 0000000000040002 00000001ffffffff ffff88801b05ff01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2, ts 12556673292, free_ts 0
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0x729/0x9e0 mm/page_alloc.c:4165
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5389
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0xce/0x3f0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x3fe/0xc30 mm/slub.c:3018
 __slab_alloc mm/slub.c:3105 [inline]
 slab_alloc_node mm/slub.c:3196 [inline]
 kmem_cache_alloc_node+0x2bb/0x370 mm/slub.c:3266
 alloc_task_struct_node kernel/fork.c:171 [inline]
 dup_task_struct+0x52/0x9a0 kernel/fork.c:883
 copy_process+0x64a/0x5aa0 kernel/fork.c:1998
 kernel_clone+0x22a/0x7e0 kernel/fork.c:2555
 kernel_thread+0x155/0x1d0 kernel/fork.c:2607
 create_kthread kernel/kthread.c:400 [inline]
 kthreadd+0x5b5/0x7a0 kernel/kthread.c:746
 ret_from_fork+0x1f/0x30
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88802452b900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88802452b980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88802452ba00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff88802452ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88802452bb00: 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] 5+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in io_poll_check_events
  2022-02-19  9:20 [syzbot] KASAN: use-after-free Read in io_poll_check_events syzbot
@ 2022-04-01  9:22 ` syzbot
  2022-04-01 12:26 ` syzbot
  1 sibling, 0 replies; 5+ messages in thread
From: syzbot @ 2022-04-01  9:22 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:    e5071887cd22 Add linux-next specific files for 20220401
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1672d26b700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=17fed8f59a304eee
dashboard link: https://syzkaller.appspot.com/bug?extid=edb9c7738ba8cbdbf197
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=1016f8f3700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14907c5b700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
CPU: 1 PID: 3567 Comm: syz-executor893 Not tainted 5.17.0-next-20220401-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:vfs_poll include/linux/poll.h:86 [inline]
RIP: 0010:io_poll_check_events+0x1e0/0x800 fs/io_uring.c:5960
Code: e8 03 48 c7 44 24 60 00 00 00 00 44 89 74 24 68 42 80 3c 28 00 0f 85 ac 05 00 00 48 8b 5d 00 48 8d 7b 28 48 89 f8 48 c1 e8 03 <42> 80 3c 28 00 0f 85 88 05 00 00 48 8b 43 28 48 8d 78 48 48 89 fa
RSP: 0018:ffffc900038ffa00 EFLAGS: 00010206
RAX: 0000000000000005 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88801cea0000 RSI: ffffffff81eba128 RDI: 0000000000000028
RBP: ffff8880182d28c0 R08: 0000000000000000 R09: ffff8880182d2947
R10: ffffffff81eba2f4 R11: 0000000000000006 R12: 0000000000000001
R13: dffffc0000000000 R14: 0000000040002038 R15: ffff8880182d2944
FS:  0000555556048300(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff954a2e140 CR3: 000000001a5af000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 io_poll_task_func+0x41/0x500 fs/io_uring.c:5995
 handle_tw_list fs/io_uring.c:2462 [inline]
 tctx_task_work+0x1a4/0x1460 fs/io_uring.c:2496
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 get_signal+0x1c5/0x24c0 kernel/signal.c:2681
 arch_do_signal_or_restart+0x88/0x1a10 arch/x86/kernel/signal.c:867
 exit_to_user_mode_loop kernel/entry/common.c:180 [inline]
 exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:215
 __syscall_exit_to_user_mode_work kernel/entry/common.c:297 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:308
 do_syscall_64+0x42/0x80 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7ff9549bcff9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 14 00 00 90 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd1be31e78 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa
RAX: 0000000000000200 RBX: 0000000000000000 RCX: 00007ff9549bcff9
RDX: 0000000000000000 RSI: 000000000000146f RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ff954980880
R13: 431bde82d7b634db R14: 0000000000000000 R15: 0000000000000000
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:vfs_poll include/linux/poll.h:86 [inline]
RIP: 0010:io_poll_check_events+0x1e0/0x800 fs/io_uring.c:5960
Code: e8 03 48 c7 44 24 60 00 00 00 00 44 89 74 24 68 42 80 3c 28 00 0f 85 ac 05 00 00 48 8b 5d 00 48 8d 7b 28 48 89 f8 48 c1 e8 03 <42> 80 3c 28 00 0f 85 88 05 00 00 48 8b 43 28 48 8d 78 48 48 89 fa
RSP: 0018:ffffc900038ffa00 EFLAGS: 00010206
RAX: 0000000000000005 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff88801cea0000 RSI: ffffffff81eba128 RDI: 0000000000000028
RBP: ffff8880182d28c0 R08: 0000000000000000 R09: ffff8880182d2947
R10: ffffffff81eba2f4 R11: 0000000000000006 R12: 0000000000000001
R13: dffffc0000000000 R14: 0000000040002038 R15: ffff8880182d2944
FS:  0000555556048300(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff954a2e140 CR3: 000000001a5af000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	e8 03 48 c7 44       	callq  0x44c74808
   5:	24 60                	and    $0x60,%al
   7:	00 00                	add    %al,(%rax)
   9:	00 00                	add    %al,(%rax)
   b:	44 89 74 24 68       	mov    %r14d,0x68(%rsp)
  10:	42 80 3c 28 00       	cmpb   $0x0,(%rax,%r13,1)
  15:	0f 85 ac 05 00 00    	jne    0x5c7
  1b:	48 8b 5d 00          	mov    0x0(%rbp),%rbx
  1f:	48 8d 7b 28          	lea    0x28(%rbx),%rdi
  23:	48 89 f8             	mov    %rdi,%rax
  26:	48 c1 e8 03          	shr    $0x3,%rax
* 2a:	42 80 3c 28 00       	cmpb   $0x0,(%rax,%r13,1) <-- trapping instruction
  2f:	0f 85 88 05 00 00    	jne    0x5bd
  35:	48 8b 43 28          	mov    0x28(%rbx),%rax
  39:	48 8d 78 48          	lea    0x48(%rax),%rdi
  3d:	48 89 fa             	mov    %rdi,%rdx


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in io_poll_check_events
  2022-02-19  9:20 [syzbot] KASAN: use-after-free Read in io_poll_check_events syzbot
  2022-04-01  9:22 ` syzbot
@ 2022-04-01 12:26 ` syzbot
  2022-04-01 14:51   ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: syzbot @ 2022-04-01 12:26 UTC (permalink / raw)
  To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs

syzbot has bisected this issue to:

commit d570aa1c4f191100f502edfc240e8d49687f62ac
Author: Jens Axboe <[email protected]>
Date:   Thu Mar 31 18:38:46 2022 +0000

    io_uring: drop the old style inflight file tracking

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=11507c5b700000
start commit:   e5071887cd22 Add linux-next specific files for 20220401
git tree:       linux-next
final oops:     https://syzkaller.appspot.com/x/report.txt?x=13507c5b700000
console output: https://syzkaller.appspot.com/x/log.txt?x=15507c5b700000
kernel config:  https://syzkaller.appspot.com/x/.config?x=17fed8f59a304eee
dashboard link: https://syzkaller.appspot.com/bug?extid=edb9c7738ba8cbdbf197
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1016f8f3700000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14907c5b700000

Reported-by: [email protected]
Fixes: d570aa1c4f19 ("io_uring: drop the old style inflight file tracking")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in io_poll_check_events
  2022-04-01 12:26 ` syzbot
@ 2022-04-01 14:51   ` Jens Axboe
  2022-04-01 15:04     ` syzbot
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2022-04-01 14:51 UTC (permalink / raw)
  To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs

On 4/1/22 6:26 AM, syzbot wrote:
> syzbot has bisected this issue to:
> 
> commit d570aa1c4f191100f502edfc240e8d49687f62ac
> Author: Jens Axboe <[email protected]>
> Date:   Thu Mar 31 18:38:46 2022 +0000
> 
>     io_uring: drop the old style inflight file tracking

#syz test git://git.kernel.dk/linux-block for-next

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] KASAN: use-after-free Read in io_poll_check_events
  2022-04-01 14:51   ` Jens Axboe
@ 2022-04-01 15:04     ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2022-04-01 15:04 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:         787c2499 Merge branch 'for-5.18/drivers' into for-next
git tree:       git://git.kernel.dk/linux-block for-next
kernel config:  https://syzkaller.appspot.com/x/.config?x=6a82c1abd4cbb9ee
dashboard link: https://syzkaller.appspot.com/bug?extid=edb9c7738ba8cbdbf197
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-01 15:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-19  9:20 [syzbot] KASAN: use-after-free Read in io_poll_check_events syzbot
2022-04-01  9:22 ` syzbot
2022-04-01 12:26 ` syzbot
2022-04-01 14:51   ` Jens Axboe
2022-04-01 15:04     ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox