linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KASAN: slab-out-of-bounds Read in garmin_read_process
@ 2020-03-21 13:40 syzbot
  2020-03-24 13:43 ` Oliver Neukum
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2020-03-21 13: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=16255ce5e00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
dashboard link: https://syzkaller.appspot.com/bug?extid=d29e9263e13ce0b9f4fd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1376a3f9e00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14c65fe3e00000

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

==================================================================
BUG: KASAN: slab-out-of-bounds in __le32_to_cpup include/uapi/linux/byteorder/little_endian.h:58 [inline]
BUG: KASAN: slab-out-of-bounds in getLayerId drivers/usb/serial/garmin_gps.c:208 [inline]
BUG: KASAN: slab-out-of-bounds in garmin_read_process+0x1b0/0x2e0 drivers/usb/serial/garmin_gps.c:1142
Read of size 4 at addr ffff8881ca74abe8 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 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
 __le32_to_cpup include/uapi/linux/byteorder/little_endian.h:58 [inline]
 getLayerId drivers/usb/serial/garmin_gps.c:208 [inline]
 garmin_read_process+0x1b0/0x2e0 drivers/usb/serial/garmin_gps.c:1142
 garmin_read_int_callback+0x19f/0x746 drivers/usb/serial/garmin_gps.c:1279
 __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


---
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 garmin_read_process
  2020-03-21 13:40 KASAN: slab-out-of-bounds Read in garmin_read_process syzbot
@ 2020-03-24 13:43 ` Oliver Neukum
  2020-03-24 14:28   ` syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Neukum @ 2020-03-24 13:43 UTC (permalink / raw)
  To: syzbot, andreyknvl, gregkh, johan, linux-kernel, linux-usb,
	syzkaller-bugs

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

Am Samstag, den 21.03.2020, 06:40 -0700 schrieb syzbot:
> 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=16255ce5e00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
> dashboard link: https://syzkaller.appspot.com/bug?extid=d29e9263e13ce0b9f4fd
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1376a3f9e00000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14c65fe3e00000

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

[-- Attachment #2: 0002-garmin_gps-add-sanity-checking-for-data-length.patch --]
[-- Type: text/x-patch, Size: 1131 bytes --]

From 36ba9c64253cc4238376b74235a163288af59638 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Tue, 24 Mar 2020 13:46:31 +0100
Subject: [PATCH 2/2] garmin_gps: add sanity checking for data length

We must not process packets shorter than a packet ID

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/serial/garmin_gps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index ffd984142171..a72fbbc65436 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1138,8 +1138,8 @@ static void garmin_read_process(struct garmin_data *garmin_data_p,
 		   send it directly to the tty port */
 		if (garmin_data_p->flags & FLAGS_QUEUING) {
 			pkt_add(garmin_data_p, data, data_length);
-		} else if (bulk_data ||
-			   getLayerId(data) == GARMIN_LAYERID_APPL) {
+		} else if (bulk_data || (data_length >= sizeof(u32) &&
+			   getLayerId(data) == GARMIN_LAYERID_APPL)) {
 
 			spin_lock_irqsave(&garmin_data_p->lock, flags);
 			garmin_data_p->flags |= APP_RESP_SEEN;
-- 
2.16.4


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

* Re: KASAN: slab-out-of-bounds Read in garmin_read_process
  2020-03-24 13:43 ` Oliver Neukum
@ 2020-03-24 14:28   ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2020-03-24 14:28 UTC (permalink / raw)
  To: andreyknvl, gregkh, johan, linux-kernel, linux-usb, oneukum,
	syzkaller-bugs

Hello,

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

Reported-and-tested-by: syzbot+d29e9263e13ce0b9f4fd@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=d29e9263e13ce0b9f4fd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
patch:          https://syzkaller.appspot.com/x/patch.diff?x=17315ad3e00000

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-24 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-21 13:40 KASAN: slab-out-of-bounds Read in garmin_read_process syzbot
2020-03-24 13:43 ` Oliver Neukum
2020-03-24 14:28   ` 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).