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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 9 Sep 2020 17:35:23 +0800
From:   Kent Gibson <warthog618@...il.com>
To:     Bartosz Golaszewski <bgolaszewski@...libre.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        linux-gpio <linux-gpio@...r.kernel.org>,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v7 07/20] gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL
 and GPIO_V2_LINE_GET_VALUES_IOCTL

On Wed, Sep 09, 2020 at 11:26:00AM +0200, Bartosz Golaszewski wrote:
> On Wed, Sep 9, 2020 at 11:24 AM Kent Gibson <warthog618@...il.com> wrote:
> >
> > On Sat, Sep 05, 2020 at 09:35:36PM +0800, Kent Gibson wrote:
> > > Add support for requesting lines using the GPIO_V2_GET_LINE_IOCTL, and
> > > returning their current values using GPIO_V2_LINE_GET_VALUES_IOCTL.
> > >
> > > The struct linereq implementation is based on the v1 struct linehandle
> > > implementation.
> > >
> > > Signed-off-by: Kent Gibson <warthog618@...il.com>
> > > ---
> > >
> >
> > [snip]
> >
> > >               if (copy_from_user(&offset, ip, sizeof(offset)))
> > >                       return -EFAULT;
> > > @@ -1104,6 +1505,25 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)
> > >                MAJOR(devt), gdev->id);
> > >
> > >       return 0;
> > > +     /*
> > > +      * array sizes must ensure 64-bit alignment and not create holes in
> > > +      * the struct packing.
> > > +      */
> > > +     BUILD_BUG_ON(IS_ALIGNED(GPIO_V2_LINES_MAX, 2));
> > > +     BUILD_BUG_ON(IS_ALIGNED(GPIO_MAX_NAME_SIZE, 8));
> > > +
> > > +     /*
> > > +      * check that uAPI structs are 64-bit aligned for 32/64-bit
> > > +      * compatibility
> > > +      */
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_attribute), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_config_attribute), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_config), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_request), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_info), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_info_changed), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_event), 8));
> > > +     BUILD_BUG_ON(IS_ALIGNED(sizeof(struct gpio_v2_line_values), 8));
> > >  }
> > >
> >
> > A couple of things here - these should all be !IS_ALIGNED.
> > And the BUILD_BUG_ON gets compiled out, and so doesn't fail, if they are
> > after the return.
> >
> > How would you like that fixed - v8 or a patch once v7 is in?
> >
> > Cheers,
> > Kent.
> 
> v8 please. Why is it compiled out though? Does it need some config option?
> 

Not sure - haven't looked into it.  I only noticed the condition was
inverted in passing, and when I flipped it it still compiled.
Moving the return to the end of the function made them all fail,
as they should if IS_ALIGNED is true.

Having BUILD_BUG_ON being able to compile out quietly is a problem in
itself.  Nothing special in my setup that I am aware of.

Cheers,
Kent.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ