lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d1ad84e3-7da9-4dc8-a095-b9fbe191eb56@rowland.harvard.edu>
Date: Tue, 4 Jun 2024 13:45:18 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Kees Cook <kees@...nel.org>
Cc: Nikita Zhandarovich <n.zhandarovich@...tech.ru>,
  Jiri Kosina <jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>,
  linux-usb@...r.kernel.org, linux-input@...r.kernel.org,
  syzkaller-bugs@...glegroups.com, linux-kernel@...r.kernel.org,
  syzbot+c52569baf0c843f35495@...kaller.appspotmail.com,
  linux-hardening@...r.kernel.org
Subject: Re: [PATCH] HID: usbhid: fix recurrent out-of-bounds bug in
 usbhid_parse()

On Tue, Jun 04, 2024 at 10:21:15AM -0700, Kees Cook wrote:
> On Tue, Jun 04, 2024 at 10:09:43AM -0700, Nikita Zhandarovich wrote:
> > Hi,
> > 
> > On 6/4/24 07:15, Jiri Kosina wrote:
> > > On Tue, 4 Jun 2024, Kees Cook wrote:
> > > 
> > >> This isn't the right solution. The problem is that hid_class_descriptor 
> > >> is a flexible array but was sized as a single element fake flexible 
> > >> array:
> > >>
> > >> struct hid_descriptor {
> > >> 	   __u8  bLength;
> > >> 	   __u8  bDescriptorType;
> > >> 	   __le16 bcdHID;
> > >> 	   __u8  bCountryCode;
> > >> 	   __u8  bNumDescriptors;
> > >>
> > >> 	   struct hid_class_descriptor desc[1];
> > >> } __attribute__ ((packed));
> > >>
> > >> This likely needs to be: 
> > >>
> > >> struct hid_class_descriptor desc[] __counted_by(bNumDescriptors);
> > >>
> > >> And then check for any sizeof() uses of the struct that might have changed.
> > > 
> > > Ah, you are of course right, not sure what I was thinking. Thanks a lot 
> > > for catching my brainfart.
> > > 
> > > I am dropping the patch for now; Nikita, will you please send a refreshed 
> > > one?
> > > 
> > 
> > Thanks for catching my mistake.
> > 
> > I'll gladly send a revised version, hoping to do it very soon.
> 
> I spent a little more time looking at this, and I'm not sure I
> understand where the actual space for the descriptors comes from?
> There's interface->extra that is being parsed, and effectively
> hid_descriptor is being mapped into it, but it uses "sizeof(struct
> hid_descriptor)" for the limit.

That's a lower limit, not an upper limit.  The hid_descriptor must 
include at least one hid_class_descriptor, but it can include more.
That's what the min_t() calculation of num_descriptors is meant to 
figure out.

>  Is more than 1 descriptor expected to
> work correctly?

More than one hid_class_descriptor -- yes.

>  Or is the limit being ignored? I'm a bit confused by
> this code...

Does this explain it?

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ