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: <201912301144.7CCEF23E@keescook>
Date:   Mon, 30 Dec 2019 11:46:29 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Navid Emamdoost <navid.emamdoost@...il.com>
Cc:     Anton Vorontsov <anton.vorontsov@...aro.org>,
        Colin Cross <ccross@...roid.com>,
        Tony Luck <tony.luck@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, emamd001@....edu
Subject: Re: [PATCH] pstore/ram: Fix memory leak in persistent_ram_new

On Wed, Dec 11, 2019 at 01:13:51PM -0600, Navid Emamdoost wrote:
> In the implementation of persistent_ram_new(), if the allocation for prz
> fails, "label" should be released as part of error handling. Release the
> label via kfree().
> 
> Fixes: 8cf5aff89e59 ("staging: android: persistent_ram: Introduce persistent_ram_new()")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>

You're right about the need to clean up the allocation, but I think it's
on the caller to do this, not persistent_ram_new(), in case a const char
string is used in the future.

I think the "Fixes" should also be:
Fixes: 1227daa43bce ("pstore/ram: Clarify resource reservation labels")

-Kees

> ---
>  fs/pstore/ram_core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
> index 8823f65888f0..7d2d86999211 100644
> --- a/fs/pstore/ram_core.c
> +++ b/fs/pstore/ram_core.c
> @@ -568,6 +568,7 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
>  	prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
>  	if (!prz) {
>  		pr_err("failed to allocate persistent ram zone\n");
> +		kfree(label);
>  		goto err;
>  	}
>  
> -- 
> 2.17.1
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ