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: <20121016043916.GB28828@linux.vnet.ibm.com>
Date:	Tue, 16 Oct 2012 10:09:16 +0530
From:	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
To:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc:	Hyeoncheol Lee <hyc.lee@...il.com>, acme@...stprotocols.net,
	LKML <linux-kernel@...r.kernel.org>,
	"yrl.pp-manager.tt@...achi.com" <yrl.pp-manager.tt@...achi.com>
Subject: Re: [PATCH] perf probe: convert_name_to_addr() allocated the wrong
 size buffer for a function name

* Masami Hiramatsu <masami.hiramatsu.pt@...achi.com> [2012-10-16 13:19:57]:

> (2012/10/16 10:37), Hyeoncheol Lee wrote:
> > convert_name_to_addr() allocated sizeof(char *) * MAX_PROBE_ARGS
> > bytes for a function name
> 
> Yeah, that one was from my laziness...
> 

Guess not your fault, but mine.

> > 
> > Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
> > Cc: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
> > Signed-off-by: Hyeoncheol Lee <hyc.lee@...il.com>
> > ---
> >  tools/perf/util/probe-event.c |    5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> > index 49a256e..bb40ed4 100644
> > --- a/tools/perf/util/probe-event.c
> > +++ b/tools/perf/util/probe-event.c
> > @@ -2352,13 +2352,14 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
> >  		free(exec_copy);
> >  	}
> >  	free(pp->function);
> > -	pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS);
> > +	pp->function = zalloc(sizeof(char) *
> > +			      (3 + sizeof(unsigned long long) * 2));
> 
> Could you comment that this is enough long here?

Also can we move the arith into a macro?

> 
> >  	if (!pp->function) {
> >  		ret = -ENOMEM;
> >  		pr_warning("Failed to allocate memory by zalloc.\n");
> >  		goto out;
> >  	}
> > -	e_snprintf(pp->function, MAX_PROBE_ARGS, "0x%llx", vaddr);
> > +	sprintf(pp->function, "0x%llx", vaddr);
> 
> And at least we should use snprintf instead of sprintf...
> (I think ret = e_snprintf(...) is better)
> 

Agree.

> >  	ret = 0;
> >  
> >  out:
> > 
> 

-- 
Thanks and Regards
Srikar

--
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