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] [day] [month] [year] [list]
Date:   Thu, 22 Jun 2023 09:47:23 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Olivier Maignial <olivier.maignial@...mail.fr>
Cc:     olivier.maignial@...fy.com, Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        Mikhail Kshevetskiy <mikhail.kshevetskiy@...sys.eu>,
        Frieder Schrempf <frieder.schrempf@...tron.de>,
        linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mtd: spinand: winbond|toshiba: Fix ecc_get_status

Hi Olivier,

olivier.maignial@...mail.fr wrote on Tue, 20 Jun 2023 23:16:15 +0200:

> Reading ECC status is failing in toshiba & winbond spi-nand drivers.
> 
> tx58cxgxsxraix_ecc_get_status() and w25n02kv_ecc_get_status()
> functions are using on-stack buffers which are not suitable
> for DMA needs of spi-mem.
> 
> Fix this by using the spi-mem operations dedicated buffer
> spinand->scratchbuf

Missing period       .

> 
> See
> spinand->scratchbuf:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/mtd/spinand.h?h=v6.3#n418
> spi_mem_check_op():
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-mem.c?h=v6.3#n199

Could you add a Cc: stable and a Fixes tag? It might require to address
both drivers independently (in two different commits), this is not a
problem.

Otherwise LGTM!

Thanks,
Miquèl

> Signed-off-by: Olivier Maignial <olivier.maignial@...mail.fr>
> ---
>  drivers/mtd/nand/spi/toshiba.c | 4 ++--
>  drivers/mtd/nand/spi/winbond.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/nand/spi/toshiba.c b/drivers/mtd/nand/spi/toshiba.c
> index 7380b1ebaccd..a80427c13121 100644
> --- a/drivers/mtd/nand/spi/toshiba.c
> +++ b/drivers/mtd/nand/spi/toshiba.c
> @@ -73,7 +73,7 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,
>  {
>  	struct nand_device *nand = spinand_to_nand(spinand);
>  	u8 mbf = 0;
> -	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
> +	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);
>  
>  	switch (status & STATUS_ECC_MASK) {
>  	case STATUS_ECC_NO_BITFLIPS:
> @@ -92,7 +92,7 @@ static int tx58cxgxsxraix_ecc_get_status(struct spinand_device *spinand,
>  		if (spi_mem_exec_op(spinand->spimem, &op))
>  			return nanddev_get_ecc_conf(nand)->strength;
>  
> -		mbf >>= 4;
> +		mbf = *(spinand->scratchbuf) >> 4;
>  
>  		if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
>  			return nanddev_get_ecc_conf(nand)->strength;
> diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
> index 3ad58cd284d8..f507e3759301 100644
> --- a/drivers/mtd/nand/spi/winbond.c
> +++ b/drivers/mtd/nand/spi/winbond.c
> @@ -108,7 +108,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
>  {
>  	struct nand_device *nand = spinand_to_nand(spinand);
>  	u8 mbf = 0;
> -	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
> +	struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);
>  
>  	switch (status & STATUS_ECC_MASK) {
>  	case STATUS_ECC_NO_BITFLIPS:
> @@ -126,7 +126,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
>  		if (spi_mem_exec_op(spinand->spimem, &op))
>  			return nanddev_get_ecc_conf(nand)->strength;
>  
> -		mbf >>= 4;
> +		mbf = *(spinand->scratchbuf) >> 4;
>  
>  		if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
>  			return nanddev_get_ecc_conf(nand)->strength;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ