linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@google.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: syzbot <syzbot+94e2b9e9c7d1dd332345@syzkaller.appspotmail.com>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, USB list <linux-usb@vger.kernel.org>
Subject: Re: KASAN: slab-out-of-bounds Write in lg4ff_init
Date: Mon, 5 Aug 2019 16:53:18 +0200	[thread overview]
Message-ID: <CAAeHK+wS2YNDgtjQ-piggaMoYTVdKrYkn=iE=G8psEHRvPYK4w@mail.gmail.com> (raw)
In-Reply-To: <1565014816.3375.1.camel@suse.com>

On Mon, Aug 5, 2019 at 4:34 PM Oliver Neukum <oneukum@suse.com> 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@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=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@suse.com>
> 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@syzkaller.appspotmail.com
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> ---
>  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
>

  parent reply	other threads:[~2019-08-05 14:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 12:38 KASAN: slab-out-of-bounds Write in lg4ff_init syzbot
2019-08-05 14:20 ` Oliver Neukum
2019-08-05 14:53   ` syzbot
2019-08-05 14:53   ` Andrey Konovalov [this message]
2019-08-06 10:27     ` Oliver Neukum
2019-08-06 10:38 ` Oliver Neukum
2019-08-06 10:49   ` syzbot

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='CAAeHK+wS2YNDgtjQ-piggaMoYTVdKrYkn=iE=G8psEHRvPYK4w@mail.gmail.com' \
    --to=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=oneukum@suse.com \
    --cc=syzbot+94e2b9e9c7d1dd332345@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).