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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 1 May 2020 16:10:03 -0400 (EDT)
From:   Alan Stern <stern@...land.harvard.edu>
To:     Arnd Bergmann <arnd@...db.de>
cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
        USB list <linux-usb@...r.kernel.org>
Subject: Re: [PATCH 08/15] usb: ehci: avoid gcc-10 zero-length-bounds warning

On Fri, 1 May 2020, Arnd Bergmann wrote:

> On Fri, May 1, 2020 at 4:42 AM Alan Stern <stern@...land.harvard.edu> wrote:
> > On Thu, 30 Apr 2020, Arnd Bergmann wrote:
> 
> >
> > No, they don't.
> 
> > >       /* PORTSC: offset 0x44 */
> > > -     u32             port_status[0]; /* up to N_PORTS */
> > > +     union {
> > > +             u32             port_status[9]; /* up to N_PORTS */
> >
> > This array can have up to 15 elements, meaning that it can extend out
> > to offset 0x80.
> 
> Ok, thanks for the clarification!
> 
> > >  /* EHCI 1.1 addendum */
> > >  #define PORTSC_SUSPEND_STS_ACK 0
> > >  #define PORTSC_SUSPEND_STS_NYET 1
> > > @@ -165,7 +166,8 @@ struct ehci_regs {
> > >  #define PORT_CONNECT (1<<0)          /* device connected */
> > >  #define PORT_RWC_BITS   (PORT_CSC | PORT_PEC | PORT_OCC)
> > >
> > > -     u32             reserved3[9];
> > > +             u32             reserved3[9];
> > > +     };
> > >
> > >       /* USBMODE: offset 0x68 */
> > >       u32             usbmode;        /* USB Device mode */
> >
> > As you see, this next field actually lies inside the preceding array.
> > It's not a real conflict; any hardware which supports the usbmode field
> > uses only the first element of the port_status array.
> >
> > I don't know how you want to handle this.  Doing
> >
> > #define usbmode port_status[9]
> >
> > doesn't seem like a very good approach, but I can't think of anything
> > better at the moment.  Maybe just set the array size to 9, as you did,
> > but with a comment explaining what's really going on.
> 
> The easiest change would be to use an anonymous struct like this
> 
>         /* PORTSC: offset 0x44 */
>         union {
>                 u32             port_status[15]; /* up to N_PORTS */
> /* EHCI 1.1 addendum */
> #define PORTSC_SUSPEND_STS_ACK 0
> ...
> #define PORT_RWC_BITS   (PORT_CSC | PORT_PEC | PORT_OCC)
>                 struct {
>                         u32             reserved3[9];
> 
>         /* USBMODE: offset 0x68 */
>                         u32             usbmode;        /* USB Device mode */
> #define USBMODE_SDIS    (1<<3)          /* Stream disable */
> #define USBMODE_BE      (1<<2)          /* BE/LE endianness select */
> #define USBMODE_CM_HC   (3<<0)          /* host controller mode */
> #define USBMODE_CM_IDLE (0<<0)          /* idle state */
> 
>                         u32             reserved4[5];
>                 };
>         };
>         u32             reserved5;
> 
> It doesn't really improve readability, but it should correctly
> reflect the layout as you described it.

Sounds good.  Please go ahead and update the patch.

Alan Stern

Powered by blists - more mailing lists