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, 5 Mar 2014 10:33:48 +0800
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Alexandre Courbot <gnurou@...il.com>
Cc:	Joe Perches <joe@...ches.com>,
	Alexandre Courbot <acourbot@...dia.com>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: clamp returned values to the boolean range

On Wed, Mar 5, 2014 at 10:22 AM, Alexandre Courbot <gnurou@...il.com> wrote:
> On Wed, Mar 5, 2014 at 11:19 AM, Joe Perches <joe@...ches.com> wrote:
>> On Wed, 2014-03-05 at 11:14 +0900, Alexandre Courbot wrote:
>>> On Wed, Mar 5, 2014 at 11:04 AM, Joe Perches <joe@...ches.com> wrote:
>>> > On Wed, 2014-03-05 at 09:49 +0800, Linus Walleij wrote:
>>> >> On Wed, Feb 26, 2014 at 9:40 AM, Alexandre Courbot <acourbot@...dia.com> wrote:
>>> >>
>>> >> > Nothing prevents GPIO drivers from returning values outside the
>>> >> > boolean range, and as it turns out a few drivers are actually doing so.
>>> >> > These values were passed as-is to unsuspecting consumers and created
>>> >> > confusion.
>>> >> >
>>> >> > This patch makes the internal _gpiod_get_raw_value() function return a
>>> >> > bool, effectively clamping the GPIO value to the boolean range no
>>> >> > matter what the driver does.
>>> >>
>>> >> No, that will not be the semantic effect of this patch, bool is just
>>> >> another name for an int, maybe some static checkers will be able
>>> >> to use it however.
>>> >
>>> > No, a bool is not an int.
>>> >
>>> > It's really different.
>>> > include/linux/types.h:typedef _Bool                     bool;
>>>
>>> It indeed seems that _Bool is an actual boolean type in C99. However I
>>> could not find in the C99 standard how ints are supposed to be
>>> converted to it.
>>
>> 6.3.1.2 Boolean type
>>
>> When any scalar value is converted to _Bool, the result is 0 if the
>> value compares equal to 0; otherwise, the result is 1.
>>
>>> So in the end it is probably safer to perform this
>>> change the way Linus suggested.
>>
>> Not really.
>
> Ok, you are obviously correct here. Linus, what do you think?

Yeah I was wrong ... too old and not keeping up with standards
development :-)

Anyway, the local "value" variable in the function should still be
converted to a bool as well right? And the assignment should still
be "false" not 0. So I would still add my hunk of code...

Yours,
Linus Walleij
--
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