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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Oct 2019 15:13:05 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     linfeilong <linfeilong@...wei.com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts: fix memleak error in read_file

On Tue, 22 Oct 2019 11:47:59 +0000 linfeilong <linfeilong@...wei.com> wrote:

> An error is found by the static code analysis tool: "memleak"
> Fix this by add free before return.
> 
> Signed-off-by: Feilong Lin <linfeilong@...wei.com>
> ---
>  scripts/insert-sys-cert.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
> index 8902836..22d99a8 100644
> --- a/scripts/insert-sys-cert.c
> +++ b/scripts/insert-sys-cert.c
> @@ -250,6 +250,7 @@ static char *read_file(char *file_name, int *size)
>  	}
>  	if (read(fd, buf, *size) != *size) {
>  		perror("File read failed");
> +		free(buf);
>  		close(fd);
>  		return NULL;
>  	}

A few lines later we do

	return buf;

so the patch adds a use-after-free error.

We could do a free(cert) down in main() or we could just do nothing -
read_file() is only called a single time.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ