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:	Fri, 23 Sep 2011 17:32:04 -0600
From:	Grant Likely <grant.likely@...retlab.ca>
To:	Michael Thalmeier <michael.thalmeier@...e.at>
Cc:	spi-devel-general@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] spi: detect wrong transfer->len values

On Fri, Sep 23, 2011 at 01:59:18PM +0200, Michael Thalmeier wrote:
> From: Helmut Raiger <helmut.raiger@...e.at>
> 
> 
> Signed-off-by: Michael Thalmeier <michael.thalmeier@...e.at>
> ---
>  drivers/spi/spi.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 4d1b9f5..70adac3 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -760,6 +760,17 @@ EXPORT_SYMBOL_GPL(spi_setup);
>  static int __spi_async(struct spi_device *spi, struct spi_message *message)
>  {
>  	struct spi_master *master = spi->master;
> +	struct spi_transfer *xfer;
> +
> +	/* check if number of bytes relates to bits per word mode */
> +	list_for_each_entry(xfer, &message->transfers, transfer_list) {
> +		u8 bpw = xfer->bits_per_word ?
> +				xfer->bits_per_word : spi->bits_per_word;
> +
> +		if ((bpw == 16 && (xfer->len & 1)) ||
> +			(bpw == 32 && (xfer->len & 3)))
> +			return -EINVAL;
> +	}

Rather than turning this into a hard fail; you should make it a
WARN_ONCE().  I wouldn't be surprised if a lot of drivers have the bad
behaviour, and applying this patch could have far reaching
consequences, including boards failing to boot.

g.

>  
>  	/* Half-duplex links include original MicroWire, and ones with
>  	 * only one data pin like SPI_3WIRE (switches direction) or where
> @@ -768,7 +779,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
>  	 */
>  	if ((master->flags & SPI_MASTER_HALF_DUPLEX)
>  			|| (spi->mode & SPI_3WIRE)) {
> -		struct spi_transfer *xfer;

Unrelated change?

>  		unsigned flags = master->flags;
>  
>  		list_for_each_entry(xfer, &message->transfers, transfer_list) {
> -- 
> 1.7.6.2
> 
> 
> 
> --
> Scanned by MailScanner.
> 
--
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