* KASAN: slab-out-of-bounds Write in ga_probe
@ 2019-09-16 13:29 syzbot
2019-09-17 18:24 ` Alan Stern
2019-10-03 18:53 ` [PATCH] HID: Fix assumption that devices have inputs Alan Stern
0 siblings, 2 replies; 8+ messages in thread
From: syzbot @ 2019-09-16 13:29 UTC (permalink / raw)
To: andreyknvl, benjamin.tissoires, jikos, linux-input, linux-kernel,
linux-usb, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: f0df5c1b 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=14045831600000
kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor,
different from the interface descriptor's value: 9
usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice=
0.00
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1: config 0 descriptor??
greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0
greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID
0e8f:0012] on usb-dummy_hcd.0-1/input0
==================================================================
BUG: KASAN: slab-out-of-bounds in set_bit
include/asm-generic/bitops-instrumented.h:28 [inline]
BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97
[inline]
BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0
drivers/hid/hid-gaff.c:146
Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78
CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: usb_hub_wq hub_event
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xca/0x13e lib/dump_stack.c:113
print_address_description+0x6a/0x32c mm/kasan/report.c:351
__kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
kasan_report+0xe/0x12 mm/kasan/common.c:618
check_memory_region_inline mm/kasan/generic.c:185 [inline]
check_memory_region+0x128/0x190 mm/kasan/generic.c:192
set_bit include/asm-generic/bitops-instrumented.h:28 [inline]
gaff_init drivers/hid/hid-gaff.c:97 [inline]
ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146
hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209
really_probe+0x281/0x6d0 drivers/base/dd.c:548
driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721
__device_attach_driver+0x
---
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] 8+ messages in thread
* Re: KASAN: slab-out-of-bounds Write in ga_probe
2019-09-16 13:29 KASAN: slab-out-of-bounds Write in ga_probe syzbot
@ 2019-09-17 18:24 ` Alan Stern
2019-09-18 11:26 ` Andrey Konovalov
2019-09-19 17:05 ` Andrey Konovalov
2019-10-03 18:53 ` [PATCH] HID: Fix assumption that devices have inputs Alan Stern
1 sibling, 2 replies; 8+ messages in thread
From: Alan Stern @ 2019-09-17 18:24 UTC (permalink / raw)
To: syzbot
Cc: andreyknvl, benjamin.tissoires, jikos, linux-input, linux-kernel,
linux-usb, syzkaller-bugs
On Mon, 16 Sep 2019, syzbot wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: f0df5c1b 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=14045831600000
> kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
> dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
>
> usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor,
> different from the interface descriptor's value: 9
> usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice=
> 0.00
> usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> usb 1-1: config 0 descriptor??
> greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0
> greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID
> 0e8f:0012] on usb-dummy_hcd.0-1/input0
> ==================================================================
> BUG: KASAN: slab-out-of-bounds in set_bit
> include/asm-generic/bitops-instrumented.h:28 [inline]
> BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97
> [inline]
> BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0
> drivers/hid/hid-gaff.c:146
> Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78
>
> CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Workqueue: usb_hub_wq hub_event
> Call Trace:
> __dump_stack lib/dump_stack.c:77 [inline]
> dump_stack+0xca/0x13e lib/dump_stack.c:113
> print_address_description+0x6a/0x32c mm/kasan/report.c:351
> __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
> kasan_report+0xe/0x12 mm/kasan/common.c:618
> check_memory_region_inline mm/kasan/generic.c:185 [inline]
> check_memory_region+0x128/0x190 mm/kasan/generic.c:192
> set_bit include/asm-generic/bitops-instrumented.h:28 [inline]
> gaff_init drivers/hid/hid-gaff.c:97 [inline]
> ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146
> hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209
> really_probe+0x281/0x6d0 drivers/base/dd.c:548
> driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721
> __device_attach_driver+0x
>
>
> ---
> 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
The driver assumes that the device contains an input.
Alan Stern
https://github.com/google/kasan.git f0df5c1b
drivers/hid/hid-gaff.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
Index: usb-devel/drivers/hid/hid-gaff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-gaff.c
+++ usb-devel/drivers/hid/hid-gaff.c
@@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
{
struct gaff_device *gaff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct list_head *report_ptr = report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KASAN: slab-out-of-bounds Write in ga_probe
2019-09-17 18:24 ` Alan Stern
@ 2019-09-18 11:26 ` Andrey Konovalov
2019-09-18 12:07 ` syzbot
2019-09-19 17:05 ` Andrey Konovalov
1 sibling, 1 reply; 8+ messages in thread
From: Andrey Konovalov @ 2019-09-18 11:26 UTC (permalink / raw)
To: Alan Stern
Cc: syzbot, Benjamin Tissoires, Jiri Kosina, linux-input, LKML,
USB list, syzkaller-bugs
[-- Attachment #1: Type: text/plain, Size: 4774 bytes --]
On Tue, Sep 17, 2019 at 8:24 PM Alan Stern <stern@rowland.harvard.edu> wrote:
>
> On Mon, 16 Sep 2019, syzbot wrote:
>
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit: f0df5c1b 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=14045831600000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
> > dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
> > compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
> >
> > usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor,
> > different from the interface descriptor's value: 9
> > usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice=
> > 0.00
> > usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > usb 1-1: config 0 descriptor??
> > greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0
> > greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID
> > 0e8f:0012] on usb-dummy_hcd.0-1/input0
> > ==================================================================
> > BUG: KASAN: slab-out-of-bounds in set_bit
> > include/asm-generic/bitops-instrumented.h:28 [inline]
> > BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97
> > [inline]
> > BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0
> > drivers/hid/hid-gaff.c:146
> > Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78
> >
> > CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Workqueue: usb_hub_wq hub_event
> > Call Trace:
> > __dump_stack lib/dump_stack.c:77 [inline]
> > dump_stack+0xca/0x13e lib/dump_stack.c:113
> > print_address_description+0x6a/0x32c mm/kasan/report.c:351
> > __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
> > kasan_report+0xe/0x12 mm/kasan/common.c:618
> > check_memory_region_inline mm/kasan/generic.c:185 [inline]
> > check_memory_region+0x128/0x190 mm/kasan/generic.c:192
> > set_bit include/asm-generic/bitops-instrumented.h:28 [inline]
> > gaff_init drivers/hid/hid-gaff.c:97 [inline]
> > ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146
> > hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209
> > really_probe+0x281/0x6d0 drivers/base/dd.c:548
> > driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721
> > __device_attach_driver+0x
> >
> >
> > ---
> > 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
>
> The driver assumes that the device contains an input.
>
> Alan Stern
>
> https://github.com/google/kasan.git f0df5c1b
You've forgotten "syz test" here :)
#syz test: https://github.com/google/kasan.git f0df5c1b
>
> drivers/hid/hid-gaff.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> Index: usb-devel/drivers/hid/hid-gaff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-gaff.c
> +++ usb-devel/drivers/hid/hid-gaff.c
> @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
> {
> struct gaff_device *gaff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> struct list_head *report_ptr = report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
>
[-- Attachment #2: hid-gaff.patch --]
[-- Type: text/x-patch, Size: 934 bytes --]
Index: usb-devel/drivers/hid/hid-gaff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-gaff.c
+++ usb-devel/drivers/hid/hid-gaff.c
@@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
{
struct gaff_device *gaff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct list_head *report_ptr = report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KASAN: slab-out-of-bounds Write in ga_probe
2019-09-18 11:26 ` Andrey Konovalov
@ 2019-09-18 12:07 ` syzbot
0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2019-09-18 12:07 UTC (permalink / raw)
To: andreyknvl, benjamin.tissoires, jikos, linux-input, linux-kernel,
linux-usb, stern, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger
crash:
Reported-and-tested-by:
syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
Tested on:
commit: f0df5c1b usb-fuzzer: main usb gadget fuzzer driver
git tree: https://github.com/google/kasan.git
kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
patch: https://syzkaller.appspot.com/x/patch.diff?x=131651c9600000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KASAN: slab-out-of-bounds Write in ga_probe
2019-09-17 18:24 ` Alan Stern
2019-09-18 11:26 ` Andrey Konovalov
@ 2019-09-19 17:05 ` Andrey Konovalov
2019-09-19 19:19 ` Alan Stern
1 sibling, 1 reply; 8+ messages in thread
From: Andrey Konovalov @ 2019-09-19 17:05 UTC (permalink / raw)
To: Alan Stern
Cc: syzbot, Benjamin Tissoires, Jiri Kosina, linux-input, LKML,
USB list, syzkaller-bugs
On Tue, Sep 17, 2019 at 8:24 PM Alan Stern <stern@rowland.harvard.edu> wrote:
>
> On Mon, 16 Sep 2019, syzbot wrote:
>
> > Hello,
> >
> > syzbot found the following crash on:
> >
> > HEAD commit: f0df5c1b 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=14045831600000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
> > dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
> > compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
> >
> > usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor,
> > different from the interface descriptor's value: 9
> > usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice=
> > 0.00
> > usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > usb 1-1: config 0 descriptor??
> > greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0
> > greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID
> > 0e8f:0012] on usb-dummy_hcd.0-1/input0
> > ==================================================================
> > BUG: KASAN: slab-out-of-bounds in set_bit
> > include/asm-generic/bitops-instrumented.h:28 [inline]
> > BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97
> > [inline]
> > BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0
> > drivers/hid/hid-gaff.c:146
> > Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78
> >
> > CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Workqueue: usb_hub_wq hub_event
> > Call Trace:
> > __dump_stack lib/dump_stack.c:77 [inline]
> > dump_stack+0xca/0x13e lib/dump_stack.c:113
> > print_address_description+0x6a/0x32c mm/kasan/report.c:351
> > __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
> > kasan_report+0xe/0x12 mm/kasan/common.c:618
> > check_memory_region_inline mm/kasan/generic.c:185 [inline]
> > check_memory_region+0x128/0x190 mm/kasan/generic.c:192
> > set_bit include/asm-generic/bitops-instrumented.h:28 [inline]
> > gaff_init drivers/hid/hid-gaff.c:97 [inline]
> > ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146
> > hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209
> > really_probe+0x281/0x6d0 drivers/base/dd.c:548
> > driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721
> > __device_attach_driver+0x
> >
> >
> > ---
> > 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
>
> The driver assumes that the device contains an input.
BTW, these two reports look fairly similar:
https://syzkaller.appspot.com/bug?extid=94e2b9e9c7d1dd332345
https://syzkaller.appspot.com/bug?extid=1e86e2ccce227cca899b
>
> Alan Stern
>
> https://github.com/google/kasan.git f0df5c1b
>
> drivers/hid/hid-gaff.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> Index: usb-devel/drivers/hid/hid-gaff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-gaff.c
> +++ usb-devel/drivers/hid/hid-gaff.c
> @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
> {
> struct gaff_device *gaff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> struct list_head *report_ptr = report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: KASAN: slab-out-of-bounds Write in ga_probe
2019-09-19 17:05 ` Andrey Konovalov
@ 2019-09-19 19:19 ` Alan Stern
0 siblings, 0 replies; 8+ messages in thread
From: Alan Stern @ 2019-09-19 19:19 UTC (permalink / raw)
To: Andrey Konovalov
Cc: syzbot, Benjamin Tissoires, Jiri Kosina, linux-input, LKML,
USB list, syzkaller-bugs
On Thu, 19 Sep 2019, Andrey Konovalov wrote:
> On Tue, Sep 17, 2019 at 8:24 PM Alan Stern <stern@rowland.harvard.edu> wrote:
> >
> > On Mon, 16 Sep 2019, syzbot wrote:
> >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit: f0df5c1b 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=14045831600000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=5c6633fa4ed00be5
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=403741a091bf41d4ae79
> > > compiler: gcc (GCC) 9.0.0 20181231 (experimental)
> > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c1e62d600000
> > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166a3a95600000
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
> > >
> > > usb 1-1: config 0 interface 0 altsetting 0 has 1 endpoint descriptor,
> > > different from the interface descriptor's value: 9
> > > usb 1-1: New USB device found, idVendor=0e8f, idProduct=0012, bcdDevice=
> > > 0.00
> > > usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > > usb 1-1: config 0 descriptor??
> > > greenasia 0003:0E8F:0012.0001: unknown main item tag 0x0
> > > greenasia 0003:0E8F:0012.0001: hidraw0: USB HID v0.00 Device [HID
> > > 0e8f:0012] on usb-dummy_hcd.0-1/input0
> > > ==================================================================
> > > BUG: KASAN: slab-out-of-bounds in set_bit
> > > include/asm-generic/bitops-instrumented.h:28 [inline]
> > > BUG: KASAN: slab-out-of-bounds in gaff_init drivers/hid/hid-gaff.c:97
> > > [inline]
> > > BUG: KASAN: slab-out-of-bounds in ga_probe+0x1fd/0x6f0
> > > drivers/hid/hid-gaff.c:146
> > > Write of size 8 at addr ffff8881d9acafc0 by task kworker/1:1/78
> > >
> > > CPU: 1 PID: 78 Comm: kworker/1:1 Not tainted 5.3.0-rc7+ #0
> > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > > Google 01/01/2011
> > > Workqueue: usb_hub_wq hub_event
> > > Call Trace:
> > > __dump_stack lib/dump_stack.c:77 [inline]
> > > dump_stack+0xca/0x13e lib/dump_stack.c:113
> > > print_address_description+0x6a/0x32c mm/kasan/report.c:351
> > > __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
> > > kasan_report+0xe/0x12 mm/kasan/common.c:618
> > > check_memory_region_inline mm/kasan/generic.c:185 [inline]
> > > check_memory_region+0x128/0x190 mm/kasan/generic.c:192
> > > set_bit include/asm-generic/bitops-instrumented.h:28 [inline]
> > > gaff_init drivers/hid/hid-gaff.c:97 [inline]
> > > ga_probe+0x1fd/0x6f0 drivers/hid/hid-gaff.c:146
> > > hid_device_probe+0x2be/0x3f0 drivers/hid/hid-core.c:2209
> > > really_probe+0x281/0x6d0 drivers/base/dd.c:548
> > > driver_probe_device+0x101/0x1b0 drivers/base/dd.c:721
> > > __device_attach_driver+0x
> > >
> > >
> > > ---
> > > 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
> >
> > The driver assumes that the device contains an input.
>
> BTW, these two reports look fairly similar:
>
> https://syzkaller.appspot.com/bug?extid=94e2b9e9c7d1dd332345
> https://syzkaller.appspot.com/bug?extid=1e86e2ccce227cca899b
Indeed they do. I don't have time to patch them now; maybe next week.
Unless you or someone else would like to do it first... :-)
Essentially the same fix should work for each of these -- looks like
they were written using copy-and-paste. In fact, a quick grep through
drivers/hid/*.c shows about 9 of them with the same suspect
initialization code for hidinput.
Alan Stern
> > drivers/hid/hid-gaff.c | 12 +++++++++---
> > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > Index: usb-devel/drivers/hid/hid-gaff.c
> > ===================================================================
> > --- usb-devel.orig/drivers/hid/hid-gaff.c
> > +++ usb-devel/drivers/hid/hid-gaff.c
> > @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
> > {
> > struct gaff_device *gaff;
> > struct hid_report *report;
> > - struct hid_input *hidinput = list_entry(hid->inputs.next,
> > - struct hid_input, list);
> > + struct hid_input *hidinput;
> > struct list_head *report_list =
> > &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> > struct list_head *report_ptr = report_list;
> > - struct input_dev *dev = hidinput->input;
> > + struct input_dev *dev;
> > int error;
> >
> > + if (list_empty(&hid->inputs)) {
> > + hid_err(hid, "no inputs found\n");
> > + return -ENODEV;
> > + }
> > + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> > + dev = hidinput->input;
> > +
> > if (list_empty(report_list)) {
> > hid_err(hid, "no output reports found\n");
> > return -ENODEV;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] HID: Fix assumption that devices have inputs
2019-09-16 13:29 KASAN: slab-out-of-bounds Write in ga_probe syzbot
2019-09-17 18:24 ` Alan Stern
@ 2019-10-03 18:53 ` Alan Stern
2019-10-04 15:47 ` Benjamin Tissoires
1 sibling, 1 reply; 8+ messages in thread
From: Alan Stern @ 2019-10-03 18:53 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, USB list, syzkaller-bugs
The syzbot fuzzer found a slab-out-of-bounds write bug in the hid-gaff
driver. The problem is caused by the driver's assumption that the
device must have an input report. While this will be true for all
normal HID input devices, a suitably malicious device can violate the
assumption.
The same assumption is present in over a dozen other HID drivers.
This patch fixes them by checking that the list of hid_inputs for the
hid_device is nonempty before allowing it to be used.
Reported-and-tested-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
---
[as1921]
drivers/hid/hid-axff.c | 11 +++++++++--
drivers/hid/hid-dr.c | 12 +++++++++---
drivers/hid/hid-emsff.c | 12 +++++++++---
drivers/hid/hid-gaff.c | 12 +++++++++---
drivers/hid/hid-holtekff.c | 12 +++++++++---
drivers/hid/hid-lg2ff.c | 12 +++++++++---
drivers/hid/hid-lg3ff.c | 11 +++++++++--
drivers/hid/hid-lg4ff.c | 11 +++++++++--
drivers/hid/hid-lgff.c | 11 +++++++++--
drivers/hid/hid-logitech-hidpp.c | 11 +++++++++--
drivers/hid/hid-microsoft.c | 12 +++++++++---
drivers/hid/hid-sony.c | 12 +++++++++---
drivers/hid/hid-tmff.c | 12 +++++++++---
drivers/hid/hid-zpff.c | 12 +++++++++---
14 files changed, 126 insertions(+), 37 deletions(-)
Index: usb-devel/drivers/hid/hid-gaff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-gaff.c
+++ usb-devel/drivers/hid/hid-gaff.c
@@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
{
struct gaff_device *gaff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct list_head *report_ptr = report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
Index: usb-devel/drivers/hid/hid-axff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-axff.c
+++ usb-devel/drivers/hid/hid-axff.c
@@ -63,13 +63,20 @@ static int axff_init(struct hid_device *
{
struct axff_device *axff;
struct hid_report *report;
- struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int field_count = 0;
int i, j;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
Index: usb-devel/drivers/hid/hid-dr.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-dr.c
+++ usb-devel/drivers/hid/hid-dr.c
@@ -75,13 +75,19 @@ static int drff_init(struct hid_device *
{
struct drff_device *drff;
struct hid_report *report;
- struct hid_input *hidinput = list_first_entry(&hid->inputs,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
Index: usb-devel/drivers/hid/hid-emsff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-emsff.c
+++ usb-devel/drivers/hid/hid-emsff.c
@@ -47,13 +47,19 @@ static int emsff_init(struct hid_device
{
struct emsff_device *emsff;
struct hid_report *report;
- struct hid_input *hidinput = list_first_entry(&hid->inputs,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
Index: usb-devel/drivers/hid/hid-holtekff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-holtekff.c
+++ usb-devel/drivers/hid/hid-holtekff.c
@@ -124,13 +124,19 @@ static int holtekff_init(struct hid_devi
{
struct holtekff_device *holtekff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
+ struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
- struct input_dev *dev = hidinput->input;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
if (list_empty(report_list)) {
hid_err(hid, "no output report found\n");
return -ENODEV;
Index: usb-devel/drivers/hid/hid-lg2ff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lg2ff.c
+++ usb-devel/drivers/hid/hid-lg2ff.c
@@ -50,11 +50,17 @@ int lg2ff_init(struct hid_device *hid)
{
struct lg2ff_device *lg2ff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
int error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
/* Check that the report looks ok */
report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
if (!report)
Index: usb-devel/drivers/hid/hid-lg3ff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lg3ff.c
+++ usb-devel/drivers/hid/hid-lg3ff.c
@@ -117,12 +117,19 @@ static const signed short ff3_joystick_a
int lg3ff_init(struct hid_device *hid)
{
- struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
const signed short *ff_bits = ff3_joystick_ac;
int error;
int i;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
/* Check that the report looks ok */
if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
return -ENODEV;
Index: usb-devel/drivers/hid/hid-lg4ff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lg4ff.c
+++ usb-devel/drivers/hid/hid-lg4ff.c
@@ -1253,8 +1253,8 @@ static int lg4ff_handle_multimode_wheel(
int lg4ff_init(struct hid_device *hid)
{
- struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
@@ -1266,6 +1266,13 @@ int lg4ff_init(struct hid_device *hid)
int mmode_ret, mmode_idx = -1;
u16 real_product_id;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
/* Check that the report looks ok */
if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
return -1;
Index: usb-devel/drivers/hid/hid-lgff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-lgff.c
+++ usb-devel/drivers/hid/hid-lgff.c
@@ -115,12 +115,19 @@ static void hid_lgff_set_autocenter(stru
int lgff_init(struct hid_device* hid)
{
- struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
const signed short *ff_bits = ff_joystick;
int error;
int i;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
/* Check that the report looks ok */
if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
return -ENODEV;
Index: usb-devel/drivers/hid/hid-logitech-hidpp.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-logitech-hidpp.c
+++ usb-devel/drivers/hid/hid-logitech-hidpp.c
@@ -2084,8 +2084,8 @@ static void hidpp_ff_destroy(struct ff_d
static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
{
struct hid_device *hid = hidpp->hid_dev;
- struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
struct ff_device *ff;
@@ -2094,6 +2094,13 @@ static int hidpp_ff_init(struct hidpp_de
int error, j, num_slots;
u8 version;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
if (!dev) {
hid_err(hid, "Struct input_dev not set!\n");
return -EINVAL;
Index: usb-devel/drivers/hid/hid-microsoft.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-microsoft.c
+++ usb-devel/drivers/hid/hid-microsoft.c
@@ -328,11 +328,17 @@ static int ms_play_effect(struct input_d
static int ms_init_ff(struct hid_device *hdev)
{
- struct hid_input *hidinput = list_entry(hdev->inputs.next,
- struct hid_input, list);
- struct input_dev *input_dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *input_dev;
struct ms_data *ms = hid_get_drvdata(hdev);
+ if (list_empty(&hdev->inputs)) {
+ hid_err(hdev, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
+ input_dev = hidinput->input;
+
if (!(ms->quirks & MS_QUIRK_FF))
return 0;
Index: usb-devel/drivers/hid/hid-sony.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-sony.c
+++ usb-devel/drivers/hid/hid-sony.c
@@ -2250,9 +2250,15 @@ static int sony_play_effect(struct input
static int sony_init_ff(struct sony_sc *sc)
{
- struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
- struct hid_input, list);
- struct input_dev *input_dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *input_dev;
+
+ if (list_empty(&sc->hdev->inputs)) {
+ hid_err(sc->hdev, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(sc->hdev->inputs.next, struct hid_input, list);
+ input_dev = hidinput->input;
input_set_capability(input_dev, EV_FF, FF_RUMBLE);
return input_ff_create_memless(input_dev, NULL, sony_play_effect);
Index: usb-devel/drivers/hid/hid-tmff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-tmff.c
+++ usb-devel/drivers/hid/hid-tmff.c
@@ -114,12 +114,18 @@ static int tmff_init(struct hid_device *
struct tmff_device *tmff;
struct hid_report *report;
struct list_head *report_list;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
- struct input_dev *input_dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *input_dev;
int error;
int i;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ input_dev = hidinput->input;
+
tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL);
if (!tmff)
return -ENOMEM;
Index: usb-devel/drivers/hid/hid-zpff.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-zpff.c
+++ usb-devel/drivers/hid/hid-zpff.c
@@ -54,11 +54,17 @@ static int zpff_init(struct hid_device *
{
struct zpff_device *zpff;
struct hid_report *report;
- struct hid_input *hidinput = list_entry(hid->inputs.next,
- struct hid_input, list);
- struct input_dev *dev = hidinput->input;
+ struct hid_input *hidinput;
+ struct input_dev *dev;
int i, error;
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ return -ENODEV;
+ }
+ hidinput = list_entry(hid->inputs.next, struct hid_input, list);
+ dev = hidinput->input;
+
for (i = 0; i < 4; i++) {
report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
if (!report)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] HID: Fix assumption that devices have inputs
2019-10-03 18:53 ` [PATCH] HID: Fix assumption that devices have inputs Alan Stern
@ 2019-10-04 15:47 ` Benjamin Tissoires
0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2019-10-04 15:47 UTC (permalink / raw)
To: Alan Stern
Cc: Jiri Kosina, open list:HID CORE LAYER, USB list, syzkaller-bugs
On Thu, Oct 3, 2019 at 2:54 PM Alan Stern <stern@rowland.harvard.edu> wrote:
>
> The syzbot fuzzer found a slab-out-of-bounds write bug in the hid-gaff
> driver. The problem is caused by the driver's assumption that the
> device must have an input report. While this will be true for all
> normal HID input devices, a suitably malicious device can violate the
> assumption.
>
> The same assumption is present in over a dozen other HID drivers.
> This patch fixes them by checking that the list of hid_inputs for the
> hid_device is nonempty before allowing it to be used.
>
> Reported-and-tested-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> CC: <stable@vger.kernel.org>
Thanks Alan pushed to for-5.4/upstream-fixes
Cheers,
Benjamin
>
> ---
>
> [as1921]
>
>
> drivers/hid/hid-axff.c | 11 +++++++++--
> drivers/hid/hid-dr.c | 12 +++++++++---
> drivers/hid/hid-emsff.c | 12 +++++++++---
> drivers/hid/hid-gaff.c | 12 +++++++++---
> drivers/hid/hid-holtekff.c | 12 +++++++++---
> drivers/hid/hid-lg2ff.c | 12 +++++++++---
> drivers/hid/hid-lg3ff.c | 11 +++++++++--
> drivers/hid/hid-lg4ff.c | 11 +++++++++--
> drivers/hid/hid-lgff.c | 11 +++++++++--
> drivers/hid/hid-logitech-hidpp.c | 11 +++++++++--
> drivers/hid/hid-microsoft.c | 12 +++++++++---
> drivers/hid/hid-sony.c | 12 +++++++++---
> drivers/hid/hid-tmff.c | 12 +++++++++---
> drivers/hid/hid-zpff.c | 12 +++++++++---
> 14 files changed, 126 insertions(+), 37 deletions(-)
>
> Index: usb-devel/drivers/hid/hid-gaff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-gaff.c
> +++ usb-devel/drivers/hid/hid-gaff.c
> @@ -64,14 +64,20 @@ static int gaff_init(struct hid_device *
> {
> struct gaff_device *gaff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> struct list_head *report_ptr = report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-axff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-axff.c
> +++ usb-devel/drivers/hid/hid-axff.c
> @@ -63,13 +63,20 @@ static int axff_init(struct hid_device *
> {
> struct axff_device *axff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =&hid->report_enum[HID_OUTPUT_REPORT].report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int field_count = 0;
> int i, j;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-dr.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-dr.c
> +++ usb-devel/drivers/hid/hid-dr.c
> @@ -75,13 +75,19 @@ static int drff_init(struct hid_device *
> {
> struct drff_device *drff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_first_entry(&hid->inputs,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-emsff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-emsff.c
> +++ usb-devel/drivers/hid/hid-emsff.c
> @@ -47,13 +47,19 @@ static int emsff_init(struct hid_device
> {
> struct emsff_device *emsff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_first_entry(&hid->inputs,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output reports found\n");
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-holtekff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-holtekff.c
> +++ usb-devel/drivers/hid/hid-holtekff.c
> @@ -124,13 +124,19 @@ static int holtekff_init(struct hid_devi
> {
> struct holtekff_device *holtekff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> + struct hid_input *hidinput;
> struct list_head *report_list =
> &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> - struct input_dev *dev = hidinput->input;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (list_empty(report_list)) {
> hid_err(hid, "no output report found\n");
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-lg2ff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-lg2ff.c
> +++ usb-devel/drivers/hid/hid-lg2ff.c
> @@ -50,11 +50,17 @@ int lg2ff_init(struct hid_device *hid)
> {
> struct lg2ff_device *lg2ff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> int error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> /* Check that the report looks ok */
> report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
> if (!report)
> Index: usb-devel/drivers/hid/hid-lg3ff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-lg3ff.c
> +++ usb-devel/drivers/hid/hid-lg3ff.c
> @@ -117,12 +117,19 @@ static const signed short ff3_joystick_a
>
> int lg3ff_init(struct hid_device *hid)
> {
> - struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> const signed short *ff_bits = ff3_joystick_ac;
> int error;
> int i;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> /* Check that the report looks ok */
> if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-lg4ff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-lg4ff.c
> +++ usb-devel/drivers/hid/hid-lg4ff.c
> @@ -1253,8 +1253,8 @@ static int lg4ff_handle_multimode_wheel(
>
> int lg4ff_init(struct hid_device *hid)
> {
> - struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
> struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
> const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
> @@ -1266,6 +1266,13 @@ int lg4ff_init(struct hid_device *hid)
> int mmode_ret, mmode_idx = -1;
> u16 real_product_id;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> /* Check that the report looks ok */
> if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
> return -1;
> Index: usb-devel/drivers/hid/hid-lgff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-lgff.c
> +++ usb-devel/drivers/hid/hid-lgff.c
> @@ -115,12 +115,19 @@ static void hid_lgff_set_autocenter(stru
>
> int lgff_init(struct hid_device* hid)
> {
> - struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> const signed short *ff_bits = ff_joystick;
> int error;
> int i;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> /* Check that the report looks ok */
> if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
> return -ENODEV;
> Index: usb-devel/drivers/hid/hid-logitech-hidpp.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-logitech-hidpp.c
> +++ usb-devel/drivers/hid/hid-logitech-hidpp.c
> @@ -2084,8 +2084,8 @@ static void hidpp_ff_destroy(struct ff_d
> static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index)
> {
> struct hid_device *hid = hidpp->hid_dev;
> - struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
> const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice);
> struct ff_device *ff;
> @@ -2094,6 +2094,13 @@ static int hidpp_ff_init(struct hidpp_de
> int error, j, num_slots;
> u8 version;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> if (!dev) {
> hid_err(hid, "Struct input_dev not set!\n");
> return -EINVAL;
> Index: usb-devel/drivers/hid/hid-microsoft.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-microsoft.c
> +++ usb-devel/drivers/hid/hid-microsoft.c
> @@ -328,11 +328,17 @@ static int ms_play_effect(struct input_d
>
> static int ms_init_ff(struct hid_device *hdev)
> {
> - struct hid_input *hidinput = list_entry(hdev->inputs.next,
> - struct hid_input, list);
> - struct input_dev *input_dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *input_dev;
> struct ms_data *ms = hid_get_drvdata(hdev);
>
> + if (list_empty(&hdev->inputs)) {
> + hid_err(hdev, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hdev->inputs.next, struct hid_input, list);
> + input_dev = hidinput->input;
> +
> if (!(ms->quirks & MS_QUIRK_FF))
> return 0;
>
> Index: usb-devel/drivers/hid/hid-sony.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-sony.c
> +++ usb-devel/drivers/hid/hid-sony.c
> @@ -2250,9 +2250,15 @@ static int sony_play_effect(struct input
>
> static int sony_init_ff(struct sony_sc *sc)
> {
> - struct hid_input *hidinput = list_entry(sc->hdev->inputs.next,
> - struct hid_input, list);
> - struct input_dev *input_dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *input_dev;
> +
> + if (list_empty(&sc->hdev->inputs)) {
> + hid_err(sc->hdev, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(sc->hdev->inputs.next, struct hid_input, list);
> + input_dev = hidinput->input;
>
> input_set_capability(input_dev, EV_FF, FF_RUMBLE);
> return input_ff_create_memless(input_dev, NULL, sony_play_effect);
> Index: usb-devel/drivers/hid/hid-tmff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-tmff.c
> +++ usb-devel/drivers/hid/hid-tmff.c
> @@ -114,12 +114,18 @@ static int tmff_init(struct hid_device *
> struct tmff_device *tmff;
> struct hid_report *report;
> struct list_head *report_list;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> - struct input_dev *input_dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *input_dev;
> int error;
> int i;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + input_dev = hidinput->input;
> +
> tmff = kzalloc(sizeof(struct tmff_device), GFP_KERNEL);
> if (!tmff)
> return -ENOMEM;
> Index: usb-devel/drivers/hid/hid-zpff.c
> ===================================================================
> --- usb-devel.orig/drivers/hid/hid-zpff.c
> +++ usb-devel/drivers/hid/hid-zpff.c
> @@ -54,11 +54,17 @@ static int zpff_init(struct hid_device *
> {
> struct zpff_device *zpff;
> struct hid_report *report;
> - struct hid_input *hidinput = list_entry(hid->inputs.next,
> - struct hid_input, list);
> - struct input_dev *dev = hidinput->input;
> + struct hid_input *hidinput;
> + struct input_dev *dev;
> int i, error;
>
> + if (list_empty(&hid->inputs)) {
> + hid_err(hid, "no inputs found\n");
> + return -ENODEV;
> + }
> + hidinput = list_entry(hid->inputs.next, struct hid_input, list);
> + dev = hidinput->input;
> +
> for (i = 0; i < 4; i++) {
> report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
> if (!report)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-04 15:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16 13:29 KASAN: slab-out-of-bounds Write in ga_probe syzbot
2019-09-17 18:24 ` Alan Stern
2019-09-18 11:26 ` Andrey Konovalov
2019-09-18 12:07 ` syzbot
2019-09-19 17:05 ` Andrey Konovalov
2019-09-19 19:19 ` Alan Stern
2019-10-03 18:53 ` [PATCH] HID: Fix assumption that devices have inputs Alan Stern
2019-10-04 15:47 ` Benjamin Tissoires
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).