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]
Message-ID: <20191007105408.2b4b9fd6@xps13>
Date:   Mon, 7 Oct 2019 10:54:08 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Navid Emamdoost <navid.emamdoost@...il.com>
Cc:     emamd001@....edu, smccaman@....edu, kjlu@....edu,
        Kyungmin Park <kyungmin.park@...sung.com>,
        Richard Weinberger <richard@....at>,
        David Woodhouse <dwmw2@...radead.org>,
        Brian Norris <computersforpeace@...il.com>,
        Marek Vasut <marek.vasut@...il.com>,
        Vignesh Raghavendra <vigneshr@...com>,
        linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] mtd: onenand: prevent memory leak in onenand_scan

Hi Navid,

Navid Emamdoost <navid.emamdoost@...il.com> wrote on Fri,  4 Oct 2019
12:19:05 -0500:

> In onenand_scan if scan_bbt fails the allocated buffers for oob_buf,
> verify_buf, and page_buf should be released.
> 
> Fixes: 5988af231978 ("mtd: Flex-OneNAND support")

Missing Cc: stable@...r.kernel.org

> Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
> ---
> Changes in v2:
> 	-- added release for this->verify_buf (thanks to Miquel Raynal
> for the hint).
> ---

These three dashes are not needed.

>  drivers/mtd/nand/onenand/onenand_base.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
> index 77bd32a683e1..6329ada3f15c 100644
> --- a/drivers/mtd/nand/onenand/onenand_base.c
> +++ b/drivers/mtd/nand/onenand/onenand_base.c
> @@ -3977,8 +3977,14 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
>  	this->badblockpos = ONENAND_BADBLOCK_POS;
>  
>  	ret = this->scan_bbt(mtd);
> -	if ((!FLEXONENAND(this)) || ret)
> +	if ((!FLEXONENAND(this)) || ret) {
> +		kfree(this->oob_buf);
> +#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
> +		kfree(this->verify_buf);
> +#endif

Sorry for the ping-pong but actually, only the oob_buf and page_buf
have been introduced by the commit 5988af you point in the Fixes tag.

To help stable kernels maintainers I suggest you free the verify_buf
in a second patch which fixes:

4a8ce0b03071 mtd: onenand: allocate verify buffer in the core

> +		kfree(this->page_buf);
>  		return ret;
> +	}
>  
>  	/* Change Flex-OneNAND boundaries if required */
>  	for (i = 0; i < MAX_DIES; i++)

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ