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]
Message-ID: <CAE1zotK7nb6VVp5a3n2_fnWZQHfizg4hFFy-ZVW5fzyFwmBMcA@mail.gmail.com>
Date:	Thu, 18 Sep 2014 18:54:34 +0300
From:	Octavian Purdila <octavian.purdila@...el.com>
To:	Johan Hovold <johan@...nel.org>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Linus Walleij <linus.walleij@...aro.org>,
	Alexandre Courbot <gnurou@...il.com>, wsa@...-dreams.de,
	Samuel Ortiz <sameo@...ux.intel.com>,
	Lee Jones <lee.jones@...aro.org>,
	Arnd Bergmann <arnd@...db.de>,
	Daniel Baluta <daniel.baluta@...el.com>,
	Laurentiu Palcu <laurentiu.palcu@...el.com>,
	linux-usb@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
	linux-gpio@...r.kernel.org, linux-i2c@...r.kernel.org
Subject: Re: [PATCH v4 3/3] gpio: add support for the Diolan DLN-2 USB GPIO driver

On Thu, Sep 18, 2014 at 3:46 PM, Johan Hovold <johan@...nel.org> wrote:
> On Thu, Sep 18, 2014 at 03:43:07PM +0300, Octavian Purdila wrote:
>> On Thu, Sep 18, 2014 at 1:54 PM, Johan Hovold <johan@...nel.org> wrote:
>> > On Tue, Sep 09, 2014 at 10:24:46PM +0300, Octavian Purdila wrote:
>
>> > Either way, it looks like this could race with get_direction() if you
>> > get a set_direction() while get_direction() is retrieving the direction
>> > from the device.
>> >
>> > This would break gpio_get().
>> >
>> I don't think gpio_set_direction() and gpio_get() are allowed to race.
>
> I wrote that set_direction() and get_direction() could race, which in
> turn would break gpio_get() as you would be caching the wrong
> direction setting.
>

OK, I now see the problem. I think doing this in get_direction() will
fix the issue:

                if (!test_and_set_bit(offset, dln2->pin_dir_set))
                        set/clear_bit(offset, dln2->pin_dir);

because gpiolib calls get_direction() while requesting a pin and
request cannot race with itself. Which means that get_direction() can
not race with itself the first time it is called, when the set/clear
operation will be run.

And because we know that get_direction() is called first, we can even
remove the set/clear operation from set_direction().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ