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: <20220131144813.725f0736@xps13>
Date:   Mon, 31 Jan 2022 14:48:13 +0100
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Pratyush Yadav <p.yadav@...com>
Cc:     Mark Brown <broonie@...nel.org>,
        Tudor Ambarus <tudor.ambarus@...rochip.com>,
        Michael Walle <michael@...le.cc>,
        Takahiro Kuwano <tkuw584924@...il.com>,
        <linux-spi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] spi: spi-mem: check if data buffers are on stack

Hi Pratyush,

p.yadav@...com wrote on Mon, 31 Jan 2022 17:15:08 +0530:

> The buffers passed in the data phase must be DMA-able. Programmers often
> don't realise this requirement and pass in buffers that reside on the
> stack. This can be hard to spot when reviewing code. Reject ops if their
> data buffer is on the stack to avoid this.
> 
> Signed-off-by: Pratyush Yadav <p.yadav@...com>
> ---
>  drivers/spi/spi-mem.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index 37f4443ce9a0..b3793a2979ee 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -207,6 +207,15 @@ static int spi_mem_check_op(const struct spi_mem_op *op)
>  	    !spi_mem_buswidth_is_valid(op->data.buswidth))
>  		return -EINVAL;
>  
> +	/* Buffers must be DMA-able. */
> +	if (op->data.dir == SPI_MEM_DATA_IN &&
> +	    object_is_on_stack(op->data.buf.in))
> +		return -EINVAL;
> +
> +	if (op->data.dir == SPI_MEM_DATA_OUT &&
> +	    object_is_on_stack(op->data.buf.out))
> +		return -EINVAL;

Definitely a good idea.

This change will depend on the spi-mem-ecc series. I will soon merge
this branch into mtd/next so that any change that depends on it can be
merged in mtd/next directly, if nobody disagrees.

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ