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, 18 Feb 2009 13:04:26 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Michael Buesch <mb@...sch.de>
Cc:	dbrownell@...rs.sourceforge.net, linux-kernel@...r.kernel.org,
	openwrt-devel@...ts.openwrt.org
Subject: Re: [PATCH] spi-gpio: Sanitize MISO bitvalue

On Sun, 15 Feb 2009 16:30:41 +0100
Michael Buesch <mb@...sch.de> wrote:

> gpio_get_value() returns 0 or nonzero, but getmiso() expects 0 or 1.
> Sanitize the value to a 0/1 boolean.
> 
> Signed-off-by: Michael Buesch <mb@...sch.de>
> 
> ---
> 
> Well, we could also change the bitbang helpers in linux/spi/spi_bitbang.h
> or change the way the gpio_get_value API is defined, but I personally think
> this patch is pretty good as is.
> In any case, it fixes a real bug on platforms like the bcm47xx which
> return 0 or nonzero for gpio_get_value.
> 
> Index: linux-2.6/drivers/spi/spi_gpio.c
> ===================================================================
> --- linux-2.6.orig/drivers/spi/spi_gpio.c	2009-02-14 21:37:14.000000000 +0100
> +++ linux-2.6/drivers/spi/spi_gpio.c	2009-02-15 16:27:16.000000000 +0100
> @@ -114,7 +114,7 @@ static inline void setmosi(const struct 
>  
>  static inline int getmiso(const struct spi_device *spi)
>  {
> -	return gpio_get_value(SPI_MISO_GPIO);
> +	return !!gpio_get_value(SPI_MISO_GPIO);
>  }
>  
>  #undef pdata
> 

Seems somewhat pointless, really.  It's a very common C idiom to treat
any non-zero value as true, and the above just adds a couple more
instructions which we didn't need to execute.

If this function is speed-critical (which is what David's comment
implies) then perhaps this should be "fixed" by tightening up the
(presently apparently undocumented) interface?  And then speeding up
all the other getmiso() implementations?
--
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