From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+5a6c4ec678a0c6ee84ba@syzkaller.appspotmail.com>,
andreyknvl@google.com, syzkaller-bugs@googlegroups.com,
jikos@kernel.org, benjamin.tissoires@redhat.com,
linux-input@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: KASAN: slab-out-of-bounds Read in hidraw_ioctl
Date: Mon, 12 Aug 2019 11:32:12 +0200 [thread overview]
Message-ID: <1565602332.14671.5.camel@suse.com> (raw)
In-Reply-To: <00000000000016c09c058fdd7faa@google.com>
Am Sonntag, den 11.08.2019, 13:46 -0700 schrieb syzbot:
> syzbot has found a reproducer for the following crash on:
>
> HEAD commit: e96407b4 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=150426ba600000
> kernel config: https://syzkaller.appspot.com/x/.config?x=cfa2c18fb6a8068e
> dashboard link: https://syzkaller.appspot.com/bug?extid=5a6c4ec678a0c6ee84ba
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12725c02600000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=162163c2600000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+5a6c4ec678a0c6ee84ba@syzkaller.appspotmail.com
#syz test: https://github.com/google/kasan.git e96407b4
From 700a7cc270f06c6e9881f49e36a7722d16ee37db Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 8 Aug 2019 15:08:48 +0200
Subject: [PATCH] HID: use strnlen to not walk through kernel memory
If a device sets no phy name we must limit the range
for looking for the end of the string lest we touch
areas of memory we should not touch.
Reported-by: syzbot+5a6c4ec678a0c6ee84ba@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/hid/hidraw.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 006bd6f4f653..c7dcff6222b5 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -443,9 +443,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
}
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
- int len = strlen(hid->phys) + 1;
- if (len > _IOC_SIZE(cmd))
- len = _IOC_SIZE(cmd);
+ int len = strnlen(hid->phys, _IOC_SIZE(cmd)) + 1;
ret = copy_to_user(user_arg, hid->phys, len) ?
-EFAULT : len;
break;
--
2.16.4
next prev parent reply other threads:[~2019-08-12 9:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 12:28 KASAN: slab-out-of-bounds Read in hidraw_ioctl syzbot
2019-08-11 20:46 ` syzbot
2019-08-12 9:32 ` Oliver Neukum [this message]
2019-08-12 9:50 ` syzbot
2019-08-21 12:57 ` Andrey Konovalov
2019-08-21 12:57 ` syzbot
2019-08-21 12:57 ` syzbot
2019-08-21 12:58 ` Andrey Konovalov
2019-08-21 13:37 ` syzbot
2019-08-21 14:10 ` Andrey Konovalov
2019-08-21 16:24 ` Alan Stern
2019-08-21 16:26 ` Andrey Konovalov
2019-08-21 16:50 ` Andrey Konovalov
2019-08-21 14:40 ` Alan Stern
2019-08-21 14:51 ` syzbot
2019-08-21 15:53 ` Alan Stern
2019-08-21 16:13 ` syzbot
2019-08-21 17:27 ` [PATCH] HID: hidraw: Fix invalid read " Alan Stern
2019-08-22 7:51 ` Jiri Kosina
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=1565602332.14671.5.camel@suse.com \
--to=oneukum@suse.com \
--cc=andreyknvl@google.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+5a6c4ec678a0c6ee84ba@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 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).