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]
Message-Id: <20200508005805.9ae13059958e36ce9ebdd5aa@kernel.org>
Date:   Fri, 8 May 2020 00:58:05 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     Yunfeng Ye <yeyunfeng@...wei.com>, <linux-kernel@...r.kernel.org>,
        <hushiyuan@...wei.com>, <hewenliang4@...wei.com>,
        Masami Hiramatsu <mhiramat@...nel.org>
Subject: Re: [PATCH] tools/bootconfig: fix resource leak in apply_xbc()

On Fri, 8 May 2020 00:56:47 +0900
Masami Hiramatsu <mhiramat@...nel.org> wrote:

> On Thu, 7 May 2020 17:23:36 +0800
> Yunfeng Ye <yeyunfeng@...wei.com> wrote:
> 
> > The @data and @fd is leak in the error path of apply_xbc(), so this
> > patch fix it.
> 
> Good catch! Thanks for fixing!
> 
> Acked-by: Masami Hiramatsu <mhiramat@...nel.org>
> 

Hi Steve, can you pick this up?

Thank you,

> > 
> > Signed-off-by: Yunfeng Ye <yeyunfeng@...wei.com>
> > ---
> >  tools/bootconfig/main.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
> > index 16b9a420e6fd..001076c51712 100644
> > --- a/tools/bootconfig/main.c
> > +++ b/tools/bootconfig/main.c
> > @@ -314,6 +314,7 @@ int apply_xbc(const char *path, const char *xbc_path)
> >  	ret = delete_xbc(path);
> >  	if (ret < 0) {
> >  		pr_err("Failed to delete previous boot config: %d\n", ret);
> > +		free(data);
> >  		return ret;
> >  	}
> > 
> > @@ -321,24 +322,26 @@ int apply_xbc(const char *path, const char *xbc_path)
> >  	fd = open(path, O_RDWR | O_APPEND);
> >  	if (fd < 0) {
> >  		pr_err("Failed to open %s: %d\n", path, fd);
> > +		free(data);
> >  		return fd;
> >  	}
> >  	/* TODO: Ensure the @path is initramfs/initrd image */
> >  	ret = write(fd, data, size + 8);
> >  	if (ret < 0) {
> >  		pr_err("Failed to apply a boot config: %d\n", ret);
> > -		return ret;
> > +		goto out;
> >  	}
> >  	/* Write a magic word of the bootconfig */
> >  	ret = write(fd, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN);
> >  	if (ret < 0) {
> >  		pr_err("Failed to apply a boot config magic: %d\n", ret);
> > -		return ret;
> > +		goto out;
> >  	}
> > +out:
> >  	close(fd);
> >  	free(data);
> > 
> > -	return 0;
> > +	return ret;
> >  }
> > 
> >  int usage(void)
> > -- 
> > 1.8.3.1
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@...nel.org>


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ