From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+7d42d68643a35f71ac8a@syzkaller.appspotmail.com>,
andreyknvl@google.com, devel@driverdev.osuosl.org,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, nishkadg.linux@gmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: KASAN: slab-out-of-bounds Read in hfa384x_usbin_callback
Date: Tue, 05 May 2020 13:55:48 +0200 [thread overview]
Message-ID: <1588679748.13662.8.camel@suse.com> (raw)
In-Reply-To: <00000000000039420505a14e4951@google.com>
[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]
Am Freitag, den 20.03.2020, 12:28 -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=11d74573e00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
> dashboard link: https://syzkaller.appspot.com/bug?extid=7d42d68643a35f71ac8a
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15fa561de00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15d74573e00000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+7d42d68643a35f71ac8a@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:381 [inline]
> BUG: KASAN: slab-out-of-bounds in skb_put_data include/linux/skbuff.h:2284 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_int_rxmonitor drivers/staging/wlan-ng/hfa384x_usb.c:3412 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_rx drivers/staging/wlan-ng/hfa384x_usb.c:3312 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_callback+0x1993/0x2360 drivers/staging/wlan-ng/hfa384x_usb.c:3026
> Read of size 19671 at addr ffff8881d226413c by task swapper/0/0
#syz test: https://github.com/google/kasan.git e17994d1
[-- Attachment #2: 0001-hfa384x_usb-fix-buffer-overflow.patch --]
[-- Type: text/x-patch, Size: 1613 bytes --]
From 6dbcac8c4b645600161feafc5576657905f15d65 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Tue, 5 May 2020 13:46:26 +0200
Subject: [PATCH] hfa384x_usb: fix buffer overflow
The driver trusts the data_len coming from the hardware
without verification. That means that this opens
a vector by which an attacker can smash 64K of the heap.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/staging/wlan-ng/hfa384x_usb.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index fa1bf8b069fd..5b6497d8c9e2 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3353,9 +3353,9 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
struct hfa384x_usb_rxfrm *rxfrm)
{
struct hfa384x_rx_frame *rxdesc = &rxfrm->desc;
- unsigned int hdrlen = 0;
- unsigned int datalen = 0;
- unsigned int skblen = 0;
+ unsigned int hdrlen;
+ unsigned int datalen;
+ unsigned int skblen;
u8 *datap;
u16 fc;
struct sk_buff *skb;
@@ -3413,8 +3413,10 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
*/
skb_put_data(skb, &rxdesc->frame_control, hdrlen);
- /* If any, copy the data from the card to the skb */
- if (datalen > 0) {
+ /* If any, copy the data from the card to the skb,
+ * as long as it fits, lest we smash a buffer
+ */
+ if (datalen > 0 && datalen <= skblen - hdrlen) {
datap = skb_put_data(skb, rxfrm->data, datalen);
/* check for unencrypted stuff if WEP bit set. */
--
2.16.4
next prev parent reply other threads:[~2020-05-05 11:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 19:28 KASAN: slab-out-of-bounds Read in hfa384x_usbin_callback syzbot
2020-03-25 8:45 ` Qiujun Huang
2020-03-25 8:58 ` syzbot
[not found] ` <20200325131309.12792-1-hdanton@sina.com>
2020-03-25 13:29 ` Andrey Konovalov
2020-03-26 2:22 ` Qiujun Huang
2020-03-26 2:24 ` Qiujun Huang
2020-03-26 2:43 ` syzbot
2020-05-05 11:55 ` Oliver Neukum [this message]
2020-05-06 8:53 ` Oliver Neukum
2020-05-06 11:50 ` Andrey Konovalov
2020-05-07 15:56 ` Andrey Konovalov
2020-05-08 9:33 ` Dmitry Vyukov
2020-05-08 10:31 ` Dmitry Vyukov
2020-05-08 13:51 ` Dmitry Vyukov
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=1588679748.13662.8.camel@suse.com \
--to=oneukum@suse.com \
--cc=andreyknvl@google.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nishkadg.linux@gmail.com \
--cc=syzbot+7d42d68643a35f71ac8a@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.