[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c69cae0f-0490-20b7-9706-78d2ef2d3c73@canonical.com>
Date: Wed, 8 Nov 2017 15:57:57 +0000
From: Colin Ian King <colin.king@...onical.com>
To: David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Boris Brezillon <boris.brezillon@...e-electrons.com>,
Marek Vasut <marek.vasut@...il.com>,
Richard Weinberger <richard@....at>,
Cyrille Pitchen <cyrille.pitchen@...ev4u.fr>,
Andrea Adami <andrea.adami@...il.com>,
linux-mtd@...ts.infradead.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: NAK: [PATCH][mtd-next] mtd: sharpslpart: fix overflow on block_adr
calculation
On 08/11/17 15:46, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> Multiplying block_num and mtd->erasesize may potentially overflow
> as they are both unsigned ints and so the multiplication is evaluated
> in unsigned int arithmetic . Cast block_adr to off_t to ensure
> multiplication is off_t sized to avoid any potential overflow.
>
> Detected by CoverityScan, CID#1461264 ("Unintentional integer overflow")
>
> Fixes: fff1e32a50c0 ("mtd: sharpslpart: Add sharpslpart partition parser")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> drivers/mtd/parsers/sharpslpart.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/parsers/sharpslpart.c b/drivers/mtd/parsers/sharpslpart.c
> index 5fe0079ea5ed..b1d97aa3bac4 100644
> --- a/drivers/mtd/parsers/sharpslpart.c
> +++ b/drivers/mtd/parsers/sharpslpart.c
> @@ -244,7 +244,7 @@ static int sharpsl_nand_read_laddr(struct mtd_info *mtd,
> return -EINVAL;
>
> block_num = ftl->log2phy[log_num];
> - block_adr = block_num * mtd->erasesize;
> + block_adr = (loff_t)block_num * mtd->erasesize;
> block_ofs = mtd_mod_by_eb((u32)from, mtd);
>
> err = mtd_read(mtd, block_adr + block_ofs, len, &retlen, buf);
>
Sorry, ignore this, there is another place that does this that needs
some attention. I'll sent V2 shortly.
Powered by blists - more mailing lists