Re: [syzbot] [usb?] KASAN: slab-use-after-free Write in usb_anchor_suspend_wakeups
From: Alan Stern
Date: Sat Aug 12 2023 - 11:56:45 EST
On Sat, Aug 12, 2023 at 02:51:30AM -0700, syzbot wrote:
> syzbot has bisected this issue to:
>
> commit 9b4feb630e8e9801603f3cab3a36369e3c1cf88d
> Author: Christian Brauner <christian.brauner@xxxxxxxxxx>
> Date: Fri May 24 09:31:44 2019 +0000
>
> arch: wire-up close_range()
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1323329ba80000
> start commit: 89d77f71f493 Merge tag 'riscv-for-linus-6.4-mw1' of git://..
> git tree: upstream
> final oops: https://syzkaller.appspot.com/x/report.txt?x=10a3329ba80000
> console output: https://syzkaller.appspot.com/x/log.txt?x=1723329ba80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=d963e7536cbe545e
> dashboard link: https://syzkaller.appspot.com/bug?extid=d6b0b0ea0781c14b2ecf
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11471b84280000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10b98e2c280000
>
> Reported-by: syzbot+d6b0b0ea0781c14b2ecf@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 9b4feb630e8e ("arch: wire-up close_range()")
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection
This attribution is extremely unlikely.
The real problem seems to be some sort of race in usbtmc and the core
between URBs being added to an anchor, file I/O being stopped, and URBs
being killed or scuttled when the file is flushed.
The bug is caused by an URB completing after (or while) its anchor is
deallocated. Note that __usb_hcd_giveback_urb() removes an URB from its
anchor before calling the completion routine, but dereferences the
anchor afterward. The anchor could easily be deallocated during that
window.
Alan Stern