Re: KASAN: use-after-free Read in usbhid_power

From: Andrey Konovalov
Date: Wed Jul 24 2019 - 10:25:12 EST


On Wed, Jul 24, 2019 at 4:17 PM Oliver Neukum <oneukum@xxxxxxxx> wrote:
>
> Am Dienstag, den 23.07.2019, 05:48 -0700 schrieb syzbot:
> >
> > Freed by task 243:
> > save_stack+0x1b/0x80 /mm/kasan/common.c:71
> > set_track /mm/kasan/common.c:79 [inline]
> > __kasan_slab_free+0x130/0x180 /mm/kasan/common.c:451
> > slab_free_hook /mm/slub.c:1421 [inline]
> > slab_free_freelist_hook /mm/slub.c:1448 [inline]
> > slab_free /mm/slub.c:2994 [inline]
> > kfree+0xd7/0x280 /mm/slub.c:3949
> > skb_free_head+0x8b/0xa0 /net/core/skbuff.c:588
> > skb_release_data+0x41f/0x7c0 /net/core/skbuff.c:608
> > skb_release_all+0x46/0x60 /net/core/skbuff.c:662
> > __kfree_skb /net/core/skbuff.c:676 [inline]
> > consume_skb /net/core/skbuff.c:736 [inline]
> > consume_skb+0xc0/0x2f0 /net/core/skbuff.c:730
> > skb_free_datagram+0x16/0xf0 /net/core/datagram.c:328
> > netlink_recvmsg+0x65e/0xea0 /net/netlink/af_netlink.c:2001
> > sock_recvmsg_nosec /net/socket.c:877 [inline]
> > sock_recvmsg /net/socket.c:894 [inline]
> > sock_recvmsg+0xca/0x110 /net/socket.c:890
> > ___sys_recvmsg+0x271/0x5a0 /net/socket.c:2448
> > __sys_recvmsg+0xe9/0x1b0 /net/socket.c:2497
> > do_syscall_64+0xb7/0x560 /arch/x86/entry/common.c:301
> > entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> How reliable is this trace? It seems very likely to me that this bug
> is the same bug as
>
> syzbot <syzbot+ded1794a717e3b235226@xxxxxxxxxxxxxxxxxxxxxxxxx>
> KASAN: use-after-free Read in hidraw_ioctl
>
> which shows a race with disconnect() instead of some networking code,
> which I really cannot fathom.

To me the alloc/free stack trace doesn't seem to have anything to do
with the access stack trace here, so I wouldn't rely on them. This is
a limitation of KASAN and can happen when there's a wild memory access
or a huge out-of-bounds or some kind of a racy-use-after-free.

>
> Regards
> Oliver
>