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: <20190605160043.GA4351@zhanggen-UX430UQ>
Date:   Thu, 6 Jun 2019 00:00:43 +0800
From:   Gen Zhang <blackgod016574@...il.com>
To:     Jiri Slaby <jslaby@...e.cz>
Cc:     mturquette@...libre.com, sboyd@...nel.org,
        linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clk: fix a missing-free bug in clk_cpy_name()

On Wed, Jun 05, 2019 at 08:38:00AM +0200, Jiri Slaby wrote:
> On 31. 05. 19, 3:14, Gen Zhang wrote:
> > In clk_cpy_name(), '*dst_p'('parent->name'and 'parent->fw_name') and 
> > 'dst' are allcoted by kstrdup_const(). According to doc: "Strings 
> > allocated by kstrdup_const should be freed by kfree_const". So 
> > 'parent->name', 'parent->fw_name' and 'dst' should be freed.
> > 
> > Signed-off-by: Gen Zhang <blackgod016574@...il.com>
> > ---
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index aa51756..85c4d3f 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -3435,6 +3435,7 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist)
> >  	if (!dst)
> >  		return -ENOMEM;
> >  
> > +	kfree_const(dst);
> 
> So you are now returning a freed pointer in dst_p?
Thanks for your reply. I re-examined the code, and this kfree is 
incorrect and it should be deleted.
> 
> >  	return 0;
> >  }
> >  
> > @@ -3491,6 +3492,8 @@ static int clk_core_populate_parent_map(struct clk_core *core)
> >  				kfree_const(parents[i].name);
> >  				kfree_const(parents[i].fw_name);
> >  			} while (--i >= 0);
> > +			kfree_const(parent->name);
> > +			kfree_const(parent->fw_name);
> 
> Both of them were just freed in the loop above, no?
for (i = 0, parent = parents; i < num_parents; i++, parent++)
Is 'parent' the same as the one from the loop above?

Moreover, should 'parents[i].name' and 'parents[i].fw_name' be freed by
kfree_const()?

Thanks
Gen
> 
> thanks,
> -- 
> js
> suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ