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+7d42d68643a35f71a...@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
From 6dbcac8c4b645600161feafc5576657905f15d65 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneu...@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 <oneu...@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

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to