Re: KASAN: slab-out-of-bounds Write in lg4ff_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 5, 2019 at 4:34 PM Oliver Neukum <oneukum@xxxxxxxx> wrote:
>
> Am Montag, den 05.08.2019, 05:38 -0700 schrieb syzbot:
> > Hello,
> >
> > syzbot found 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=144c21dc600000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=cfa2c18fb6a8068e
> > dashboard link: https://syzkaller.appspot.com/bug?extid=94e2b9e9c7d1dd332345
> > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=169e8542600000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10ec8262600000
> >
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+94e2b9e9c7d1dd332345@xxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > 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=046d, idProduct=c298, bcdDevice=
> > 0.00
> > usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > usb 1-1: config 0 descriptor??
> > logitech 0003:046D:C298.0001: unknown main item tag 0x0
> > logitech 0003:046D:C298.0001: unknown main item tag 0x0
> > logitech 0003:046D:C298.0001: hidraw0: USB HID v0.00 Device [HID 046d:c298]
> > on usb-dummy_hcd.0-1/input0
> > BUG: KASAN: slab-out-of-bounds in set_bit
> > include/asm-generic/bitops-instrumented.h:28 [inline]
>
> #syz test: https://github.com/google/kasan.git e96407b4
>
> From 7e7f8ce9108b69613f8bb4ff2f95c258e22c3228 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oneukum@xxxxxxxx>
> Date: Mon, 5 Aug 2019 16:14:47 +0200
> Subject: [PATCH] hid-lg4ff: sanity check for offsets of FF effects
>
> Malicious devices could provide huge offsets which would lead
> to setting bits in random kernel memory. Adding a sanity check.
>
> Reported-by: syzbot+94e2b9e9c7d1dd332345@xxxxxxxxxxxxxxxxxxxxxxxxx
> Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx>
> ---
>  drivers/hid/hid-lg4ff.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index cefba038520c..f9572750d889 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -1327,8 +1327,12 @@ int lg4ff_init(struct hid_device *hid)
>         }
>
>         /* Set supported force feedback capabilities */
> +       error = -ENODEV;
>         for (j = 0; lg4ff_devices[i].ff_effects[j] >= 0; j++)
> -               set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit);
> +               if (lg4ff_devices[i].ff_effects[j] <= 15)

Can't ff_effects have one of the FF_CONSTANT, FF_PERIODIC, etc.
values? Those are 0x50, 0x51, ... Or maybe I'm just misunderstanding
something. Are those ff_effects provided by the device?

> +                       set_bit(lg4ff_devices[i].ff_effects[j], dev->ffbit);
> +               else
> +                       goto err_init;
>
>         error = input_ff_create_memless(dev, NULL, lg4ff_play);
>
> --
> 2.16.4
>



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux