All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+55b0304b360654a7537b@syzkaller.appspotmail.com>,
	andreyknvl@google.com, syzkaller-bugs@googlegroups.com,
	steve_bayless@keysight.com, gregkh@linuxfoundation.org,
	guido.kiener@rohde-schwarz.com, linux-usb@vger.kernel.org
Subject: Re: divide error in usbtmc_generic_read
Date: Thu, 15 Aug 2019 16:28:48 +0200	[thread overview]
Message-ID: <1565879328.5780.9.camel@suse.com> (raw)
In-Reply-To: <000000000000c4157e0590123002@google.com>

Am Mittwoch, den 14.08.2019, 04:38 -0700 schrieb syzbot:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:    d0847550 usb-fuzzer: main usb gadget fuzzer driver
> git tree:       https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=16295d4a600000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=dbc9c80cc095da19
> dashboard link: https://syzkaller.appspot.com/bug?extid=55b0304b360654a7537b
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1288a31c600000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15282e86600000
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+55b0304b360654a7537b@syzkaller.appspotmail.com

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

From df64f5cd2e6a9b43c75bb7e3276b8805a225db75 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Wed, 14 Aug 2019 15:21:41 +0200
Subject: [PATCH] usbtmc: more sanity checking for packet size

A malicious device can make the driver divide ny zero
with a nonsense maximum packet size.

V2: return a sensible error code

SIgned-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/usb/class/usbtmc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 4942122b2346..36858ddd8d9b 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -2362,8 +2362,11 @@ static int usbtmc_probe(struct usb_interface *intf,
 		goto err_put;
 	}
 
+	retcode = -EINVAL;
 	data->bulk_in = bulk_in->bEndpointAddress;
 	data->wMaxPacketSize = usb_endpoint_maxp(bulk_in);
+	if (!data->wMaxPacketSize)
+		goto err_put;
 	dev_dbg(&intf->dev, "Found bulk in endpoint at %u\n", data->bulk_in);
 
 	data->bulk_out = bulk_out->bEndpointAddress;
-- 
2.16.4


  parent reply	other threads:[~2019-08-15 14:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 11:38 divide error in usbtmc_generic_read syzbot
2019-08-14 13:25 ` Oliver Neukum
2019-08-14 13:38   ` syzbot
2019-08-14 13:52     ` Andrey Konovalov
2019-08-15 13:31     ` Oliver Neukum
2019-08-19 12:17       ` Andrey Konovalov
2019-08-19 12:37         ` Oliver Neukum
2019-08-19 12:43           ` Andrey Konovalov
2019-08-19 13:09             ` Oliver Neukum
2019-08-19 13:18               ` Andrey Konovalov
2019-08-19 13:49                 ` Oliver Neukum
2019-08-19 15:40                   ` Andrey Konovalov
2019-08-20  9:01                     ` Oliver Neukum
2019-08-15 14:28 ` Oliver Neukum [this message]
2019-08-15 14:48   ` syzbot
2019-11-19 13:35 ` Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565879328.5780.9.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=andreyknvl@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guido.kiener@rohde-schwarz.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=steve_bayless@keysight.com \
    --cc=syzbot+55b0304b360654a7537b@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.