linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows
       [not found] <CGME20181128080244eucas1p15d9478c4fdbb0609005a12d24703d6d8@eucas1p1.samsung.com>
@ 2018-11-28  8:02 ` Huijin Park
  2018-11-28  8:41   ` Geert Uytterhoeven
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Huijin Park @ 2018-11-28  8:02 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Marek Vasut, linux-mtd, linux-kernel, Huijin Park, bbanghj.park,
	Geert Uytterhoeven

From: "huijin.park" <huijin.park@samsung.com>

The "params->size" is defined as "u64".
And "info->sector_size" and "info->n_sectors" are defined as
unsigned int and u16.
Thus, u64 data might have strange data(loss data) if the result
overflows an unsigned int.
This patch casts "info->sector_size" to an u64.

Signed-off-by: huijin.park <huijin.park@samsung.com>
---

Changes since v1:
 * Made commit subject and message more clear.
Changes since v2:
 * Adding the cast to only the first operand.
---
 drivers/mtd/spi-nor/spi-nor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d9c368c..59a1075 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
 	memset(params, 0, sizeof(*params));
 
 	/* Set SPI NOR sizes. */
-	params->size = info->sector_size * info->n_sectors;
+	params->size = (u64)info->sector_size * info->n_sectors;
 	params->page_size = info->page_size;
 
 	/* (Fast) Read settings. */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows
  2018-11-28  8:02 ` [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows Huijin Park
@ 2018-11-28  8:41   ` Geert Uytterhoeven
  2018-12-03  7:51   ` [v3] " Boris Brezillon
  2018-12-03  8:12   ` [PATCH v3] " Rafał Miłecki
  2 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2018-11-28  8:41 UTC (permalink / raw)
  To: huijin.park
  Cc: Boris Brezillon, Marek Vasut, MTD Maling List,
	Linux Kernel Mailing List, bbanghj.park

On Wed, Nov 28, 2018 at 9:03 AM Huijin Park <huijin.park@samsung.com> wrote:
> From: "huijin.park" <huijin.park@samsung.com>
>
> The "params->size" is defined as "u64".
> And "info->sector_size" and "info->n_sectors" are defined as
> unsigned int and u16.
> Thus, u64 data might have strange data(loss data) if the result
> overflows an unsigned int.
> This patch casts "info->sector_size" to an u64.
>
> Signed-off-by: huijin.park <huijin.park@samsung.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v3] mtd: spi-nor: cast to u64 to avoid uint overflows
  2018-11-28  8:02 ` [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows Huijin Park
  2018-11-28  8:41   ` Geert Uytterhoeven
@ 2018-12-03  7:51   ` Boris Brezillon
  2018-12-03 10:34     ` Boris Brezillon
  2018-12-03  8:12   ` [PATCH v3] " Rafał Miłecki
  2 siblings, 1 reply; 5+ messages in thread
From: Boris Brezillon @ 2018-12-03  7:51 UTC (permalink / raw)
  To: Huijin Park, Boris Brezillon
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, linux-mtd, bbanghj.park

On Wed, 2018-11-28 at 08:02:14 UTC, Huijin Park wrote:
> From: "huijin.park" <huijin.park@samsung.com>
> 
> The "params->size" is defined as "u64".
> And "info->sector_size" and "info->n_sectors" are defined as
> unsigned int and u16.
> Thus, u64 data might have strange data(loss data) if the result
> overflows an unsigned int.
> This patch casts "info->sector_size" to an u64.
> 
> Signed-off-by: huijin.park <huijin.park@samsung.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows
  2018-11-28  8:02 ` [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows Huijin Park
  2018-11-28  8:41   ` Geert Uytterhoeven
  2018-12-03  7:51   ` [v3] " Boris Brezillon
@ 2018-12-03  8:12   ` Rafał Miłecki
  2 siblings, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2018-12-03  8:12 UTC (permalink / raw)
  To: huijin.park
  Cc: Boris Brezillon, Linux Kernel Mailing List, Marek Vasut,
	Geert Uytterhoeven, linux-mtd, bbanghj.park

On Wed, 28 Nov 2018 at 09:03, Huijin Park <huijin.park@samsung.com> wrote:
> From: "huijin.park" <huijin.park@samsung.com>
>
> The "params->size" is defined as "u64".
> And "info->sector_size" and "info->n_sectors" are defined as
> unsigned int and u16.
> Thus, u64 data might have strange data(loss data) if the result
> overflows an unsigned int.
> This patch casts "info->sector_size" to an u64.
>
> Signed-off-by: huijin.park <huijin.park@samsung.com>

You may want to adjust your git's "user.name" config to avoid
"malforming" your name (From and Signed-off-by) in the further
contributions :)

Something like
git config --global user.name "John Foo"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v3] mtd: spi-nor: cast to u64 to avoid uint overflows
  2018-12-03  7:51   ` [v3] " Boris Brezillon
@ 2018-12-03 10:34     ` Boris Brezillon
  0 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2018-12-03 10:34 UTC (permalink / raw)
  To: Huijin Park, Boris Brezillon
  Cc: linux-kernel, Marek Vasut, Geert Uytterhoeven, linux-mtd, bbanghj.park

On Mon,  3 Dec 2018 08:51:54 +0100
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> On Wed, 2018-11-28 at 08:02:14 UTC, Huijin Park wrote:
> > From: "huijin.park" <huijin.park@samsung.com>
> > 
> > The "params->size" is defined as "u64".
> > And "info->sector_size" and "info->n_sectors" are defined as
> > unsigned int and u16.
> > Thus, u64 data might have strange data(loss data) if the result
> > overflows an unsigned int.
> > This patch casts "info->sector_size" to an u64.
> > 
> > Signed-off-by: huijin.park <huijin.park@samsung.com>
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>  
> 
> Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Oops, should I been queued to spi-nor/next. I dropped the patch and
will soon push it to spi-nor/next.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-03 10:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20181128080244eucas1p15d9478c4fdbb0609005a12d24703d6d8@eucas1p1.samsung.com>
2018-11-28  8:02 ` [PATCH v3] mtd: spi-nor: cast to u64 to avoid uint overflows Huijin Park
2018-11-28  8:41   ` Geert Uytterhoeven
2018-12-03  7:51   ` [v3] " Boris Brezillon
2018-12-03 10:34     ` Boris Brezillon
2018-12-03  8:12   ` [PATCH v3] " Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).