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: <5149ED25.4010309@wwwdotorg.org>
Date:	Wed, 20 Mar 2013 11:08:53 -0600
From:	Stephen Warren <swarren@...dotorg.org>
To:	Richard Genoud <richard.genoud@...il.com>
CC:	Linus Walleij <linus.walleij@...aro.org>,
	Axel Lin <axel.lin@...ics.com>,
	Stephen Warren <swarren@...dia.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] BUG: pinmux: forbid mux_usecount to be set at UINT_MAX

On 03/20/2013 10:59 AM, Richard Genoud wrote:
> 2013/3/20 Stephen Warren <swarren@...dotorg.org>:
>> On 03/20/2013 05:31 AM, Richard Genoud wrote:
>>> If pin_free is called on a pin already freed, mux_usecount is set to
>>> UINT_MAX which is really a bad idea.
>>> This will silently ignore a double call to pin_free
>>
>> Shouldn't we WARN_ON(this case)?
> yes indeed, it may be better to issue a big warning because AFAIK
> that's not normal.
> 
>>
>>> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
>>
>>>       if (!gpio_range) {
>>> -             desc->mux_usecount--;
>>> -             if (desc->mux_usecount)
>>> +             if (1 == desc->mux_usecount)
>>> +                     desc->mux_usecount = 0;
>>> +             else
>>>                       return NULL;
>>
>> What if desc-mux_usecount was 2; this patch prevents the use-count from
>> being decremented to 1 in this case. Shouldn't this be:
>>
>>         if (!gpio_range) {
>> +               if (WARN_ON(!desc->mux_usecount))
>> +                       return NULL;
>>                 desc->mux_usecount--;
>
> Well, I'm not very familiar with this code, but can mux_usecount be
> higher than 1 ?

Possibly not, but isn't that more something that the
resource-acquisition code (i.e. whatever does mux_usecount++) should
enforce; the cleanup code should probably support all cases in case the
enforcement rules change in the future. Either that, or convert the
field to a bool so it's clear what the range is.

--
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