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: <Y4dNNAHOFU5izEbm@smile.fi.intel.com>
Date:   Wed, 30 Nov 2022 14:31:48 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     Kent Gibson <warthog618@...il.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v4 2/2] gpiolib: protect the GPIO device against being
 dropped while in use by user-space

On Wed, Nov 30, 2022 at 01:05:30PM +0100, Bartosz Golaszewski wrote:
> On Wed, Nov 30, 2022 at 1:02 PM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > On Wed, Nov 30, 2022 at 10:05:56AM +0100, Bartosz Golaszewski wrote:

> > > +     down_read(&gdev->sem);
> >
> > Thinking more about this, wouldn't be better to actually
> >
> >         ret = down_read_trylock(&gdev->sem);
> >         if (ret)
> >                 return ret;
> >
> > ?
> 
> You mean as in: try to take the lock, but if we're already removing
> the device (as the down_write() can only happen in gpiochip_remove()),
> then die right away? Smart! Yeah, I'll do it this way.

But please check return values properly (it seems not obvious what it does
return).

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ