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: <20131210134920.GO8098@ghostprotocols.net>
Date:	Tue, 10 Dec 2013 10:49:20 -0300
From:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	Adrian Hunter <adrian.hunter@...el.com>,
	linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
	Ben Cheng <bccheng@...gle.com>,
	David Ahern <dsahern@...il.com>,
	Dongsheng Yang <yangds.fnst@...fujitsu.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Jiri Olsa <jolsa@...hat.com>, Mike Galbraith <efault@....de>,
	Namhyung Kim <namhyung.kim@....com>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Stephane Eranian <eranian@...gle.com>,
	Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [GIT PULL 00/21] perf/core improvements and fixes

Em Tue, Dec 10, 2013 at 01:18:01PM +0100, Ingo Molnar escreveu:
> 
> * Adrian Hunter <adrian.hunter@...el.com> wrote:
> 
> > -void dso__set_short_name(struct dso *dso, const char *name)
> > +void dso__set_short_name(struct dso *dso, const char *name, bool sname_alloc)
> >  {
> >  	if (name == NULL)
> >  		return;
> > +	if (dso->sname_alloc)
> > +		free((char *)dso->short_name);
> > +	dso->sname_alloc = sname_alloc;
> 
> Calling the function option the same as the field name is asking for 
> trouble - I'd suggest 'new_sname_alloc' for the parameter, or so.
> 
> And I'd also remove the 'const' from struct dso::short_name, it 
> probably does not help code generation, because 'dso' is passed in as 
> const in all the non-lifetime methods anyway.
 
> That way the cast can be dropped from the free().

Not that simple, there are multiple places that pass a constant
short_name, for instance:

	machine__get_kernel()
                kernel = dso__kernel_findnew(machine, vmlinux_name,
					     "[kernel]", DSO_TYPE_KERNEL);
			dso__set_short_name(dso, short_name);

So dso->short_name will point to "[kernel]", which is a const char *.

> Similar problems exist with the usage of 'short_name' - it overloads 
> the field name which makes it somewhat confusing, and it's also 
> sometimes inconsistently named, such as 'name' in 
> dso__set_short_name().
> 
> Ditto for 'long_name' handling.
> 
> Also, the 'sname_alloc' name sucks, it does not make it obvious that 

> it's related to 'short_name', hiding its true significance (and hiding 
> the broken life time handling of the flag/pointer combo). I'd rename 
> it to something more descriptive, like ->short_name_allocated - or I'd 
> rename everything to 'sname'/'lname' naming for short/long names.

Ok, we can use rename it to short_name_alloc, like we have
short_name_len.
 
> Every time one runs into a crash like this it's a canary signal that 
> cleanliness principles need hardening.

Hardening we go then!
 
> Thanks,
> 
> 	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ