linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KASAN: slab-out-of-bounds Read in edge_interrupt_callback
@ 2020-03-23 12:40 syzbot
  2020-03-25  7:26 ` Qiujun Huang
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2020-03-23 12:40 UTC (permalink / raw)
  To: andreyknvl, gregkh, johan, linux-kernel, linux-usb, syzkaller-bugs

Hello,

syzbot found the following crash on:

HEAD commit:    e17994d1 usb: core: kcov: collect coverage from usb comple..
git tree:       https://github.com/google/kasan.git usb-fuzzer
console output: https://syzkaller.appspot.com/x/log.txt?x=13706939e00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
dashboard link: https://syzkaller.appspot.com/bug?extid=37ba33391ad5f3935bbd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=150d3841e00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12842b19e00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+37ba33391ad5f3935bbd@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: slab-out-of-bounds in edge_interrupt_callback+0x8be/0x9d0 drivers/usb/serial/io_edgeport.c:715
Read of size 1 at addr ffff8881d2920c67 by task swapper/0/0

CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xef/0x16e lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x314 mm/kasan/report.c:374
 __kasan_report.cold+0x37/0x77 mm/kasan/report.c:506
 kasan_report+0xe/0x20 mm/kasan/common.c:641
 edge_interrupt_callback+0x8be/0x9d0 drivers/usb/serial/io_edgeport.c:715
 __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650
 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716
 dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966
 call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404


---
This bug 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 syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: KASAN: slab-out-of-bounds Read in edge_interrupt_callback
  2020-03-23 12:40 KASAN: slab-out-of-bounds Read in edge_interrupt_callback syzbot
@ 2020-03-25  7:26 ` Qiujun Huang
  2020-03-25  7:44   ` syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Qiujun Huang @ 2020-03-25  7:26 UTC (permalink / raw)
  To: syzbot
  Cc: Andrey Konovalov, Greg KH, johan, linux-kernel, linux-usb,
	syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]

#syz test: https://github.com/google/kasan.git e17994d1

On Mon, Mar 23, 2020 at 8:40 PM syzbot
<syzbot+37ba33391ad5f3935bbd@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:    e17994d1 usb: core: kcov: collect coverage from usb comple..
> git tree:       https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=13706939e00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
> dashboard link: https://syzkaller.appspot.com/bug?extid=37ba33391ad5f3935bbd
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=150d3841e00000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12842b19e00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+37ba33391ad5f3935bbd@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in edge_interrupt_callback+0x8be/0x9d0 drivers/usb/serial/io_edgeport.c:715
> Read of size 1 at addr ffff8881d2920c67 by task swapper/0/0
>
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0-rc5-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
>  <IRQ>
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0xef/0x16e lib/dump_stack.c:118
>  print_address_description.constprop.0.cold+0xd3/0x314 mm/kasan/report.c:374
>  __kasan_report.cold+0x37/0x77 mm/kasan/report.c:506
>  kasan_report+0xe/0x20 mm/kasan/common.c:641
>  edge_interrupt_callback+0x8be/0x9d0 drivers/usb/serial/io_edgeport.c:715
>  __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650
>  usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716
>  dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966
>  call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404
>
>
> ---
> This bug 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 syzkaller@googlegroups.com.
>
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches

[-- Attachment #2: 0003-USB-io_edgeport-fix-slab-out-of-bounds-Read-in-edge_.patch --]
[-- Type: application/octet-stream, Size: 1102 bytes --]

From de43cd1e7e16856f7bfc63e1ee41d2fd08a3d580 Mon Sep 17 00:00:00 2001
From: Qiujun Huang <hqjagain@gmail.com>
Date: Wed, 25 Mar 2020 15:17:18 +0800
Subject: [PATCH 3/3] USB: io_edgeport: fix  slab-out-of-bounds Read in
 edge_interrupt_callback

The boundary condition should be (length - 1) as we access data[position+1].

Reported-by: syzbot+37ba33391ad5f3935bbd@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
 drivers/usb/serial/io_edgeport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 5737add..4cca0b8 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -710,7 +710,7 @@ static void edge_interrupt_callback(struct urb *urb)
 		/* grab the txcredits for the ports if available */
 		position = 2;
 		portNumber = 0;
-		while ((position < length) &&
+		while ((position < length - 1) &&
 				(portNumber < edge_serial->serial->num_ports)) {
 			txCredits = data[position] | (data[position+1] << 8);
 			if (txCredits) {
-- 
1.8.3.1


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

* Re: KASAN: slab-out-of-bounds Read in edge_interrupt_callback
  2020-03-25  7:26 ` Qiujun Huang
@ 2020-03-25  7:44   ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2020-03-25  7:44 UTC (permalink / raw)
  To: andreyknvl, anenbupt, gregkh, johan, linux-kernel, linux-usb,
	syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger crash:

Reported-and-tested-by: syzbot+37ba33391ad5f3935bbd@syzkaller.appspotmail.com

Tested on:

commit:         e17994d1 usb: core: kcov: collect coverage from usb comple..
git tree:       https://github.com/google/kasan.git
kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
dashboard link: https://syzkaller.appspot.com/bug?extid=37ba33391ad5f3935bbd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=165cc813e00000

Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2020-03-25  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 12:40 KASAN: slab-out-of-bounds Read in edge_interrupt_callback syzbot
2020-03-25  7:26 ` Qiujun Huang
2020-03-25  7:44   ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).