Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1607550

Re: usb: use-after-free write in usb_hcd_link_urb_to_ep

From Alan Stern <stern@rowland.harvard.edu>
Newsgroups linux.kernel
Subject Re: usb: use-after-free write in usb_hcd_link_urb_to_ep
Date 2017-03-23 15:40 +0100
Message-ID <toc4a-3pL-19@gated-at.bofh.it> (permalink)
References <to9SF-25x-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 23 Mar 2017, Dmitry Vyukov wrote:

> Hello,
> 
> I've got the following report while running syzkaller fuzzer on
> 093b995e3b55a0ae0670226ddfcb05bfbf0099ae. Not the preceding injected
> kmalloc failure, most likely it's the root cause.

I find this bug report puzzling.  Maybe I don't understand it 
correctly -- it appears that the so-called use-after-free actually 
occurs _before_ the memory is deallocated!

> FAULT_INJECTION: forcing a failure.
Skipping this part.  Is it relevant?  It seems to refer to a different
memory buffer.

> ==================================================================
> BUG: KASAN: use-after-free in __list_add_valid+0xc6/0xd0
> lib/list_debug.c:26 at addr ffff88003c377a20
> Read of size 8 by task syz-executor7/3348
> CPU: 3 PID: 3348 Comm: syz-executor7 Not tainted 4.11.0-rc3+ #364
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Call Trace:

Here are the revelant pieces of the stack traces.  Everything below
these parts is the same, and everything above them is unimportant.  
(And everything happened in the same process.)  The use-after-free
access occurred within this call:

>  usb_start_wait_urb+0x135/0x320 drivers/usb/core/message.c:56
>  usb_internal_control_msg drivers/usb/core/message.c:100 [inline]


Here's where the allocation call occurred:

> Allocated:
> PID = 3348
...
>  usb_internal_control_msg drivers/usb/core/message.c:93 [inline]


And here's where the buffer was deallocated:

> Freed:
> PID = 3348
...
>  usb_start_wait_urb+0x234/0x320 drivers/usb/core/message.c:78
>  usb_internal_control_msg drivers/usb/core/message.c:100 [inline]

Putting these together:

	The memory was allocated in usb_internal_control_msg() line 93.
	The later events occurred within the call in line 100 to
	usb_start_wait_urb().

	The invalid access occurred within usb_start_wait_urb() line 56.

	The memory was deallocated within usb_start_wait_urb() line 78.

Since these routines don't involve any loops or backward jumps, this 
says that the invalid access occurred before the memory was 
deallocated!  So why is it reported as a problem?

Alan

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

usb: use-after-free write in usb_hcd_link_urb_to_ep Dmitry Vyukov <dvyukov@google.com> - 2017-03-23 13:20 +0100
  Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Alan Stern <stern@rowland.harvard.edu> - 2017-03-23 15:40 +0100
    Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Dmitry Vyukov <dvyukov@google.com> - 2017-03-23 15:50 +0100
      Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Alan Stern <stern@rowland.harvard.edu> - 2017-03-23 16:10 +0100
        Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Dmitry Vyukov <dvyukov@google.com> - 2017-03-23 16:30 +0100
          Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Dmitry Vyukov <dvyukov@google.com> - 2017-03-24 11:40 +0100
            Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Alan Stern <stern@rowland.harvard.edu> - 2017-03-24 15:30 +0100
              Re: usb: use-after-free write in usb_hcd_link_urb_to_ep Dmitry Vyukov <dvyukov@google.com> - 2017-03-24 18:20 +0100

csiph-web