All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Hyeoncheol Lee <hyc.lee@gmail.com>
Cc: acme@ghostprotocols.net, LKML <linux-kernel@vger.kernel.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	"yrl.pp-manager.tt@hitachi.com" <yrl.pp-manager.tt@hitachi.com>
Subject: Re: [PATCH v2] perf probe: convert_name_to_addr() allocated the wrong size buffers for names
Date: Thu, 18 Oct 2012 17:31:12 +0900	[thread overview]
Message-ID: <507FBE50.1060603@hitachi.com> (raw)
In-Reply-To: <1350523077-21258-1-git-send-email-hyc.lee@gmail.com>

(2012/10/18 10:17), Hyeoncheol Lee wrote:
> The function allocated wrong size buffers for names
> 
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Signed-off-by: Hyeoncheol Lee <hyc.lee@gmail.com>

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thanks!


> ---
>  v2: - Added a comment for MAX_ADDRNAME_LEN
> 
>  tools/perf/util/probe-event.c |   17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 49a256e..661bbdf 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2274,6 +2274,14 @@ int show_available_funcs(const char *target, struct strfilter *_filter,
>  }
>  
>  /*
> + * MAX_ADDRNAME_LEN is the maximum length of a function name for uprobe_events
> + * Because each half byte is encoded in one hex character,
> + * sizeof(type)*2 is the maximum length of hexadecimal number of the type.
> + * Another 3 bytes are for "0x" and a null character
> + */
> +#define MAX_ADDRNAME_LEN  (3 + sizeof(unsigned long long) * 2)
> +
> +/*
>   * uprobe_events only accepts address:
>   * Convert function and any offset to address
>   */
> @@ -2332,7 +2340,7 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
>  	if (!pev->group) {
>  		char *ptr1, *ptr2, *exec_copy;
>  
> -		pev->group = zalloc(sizeof(char *) * 64);
> +		pev->group = zalloc(sizeof(char) * 64);
>  		exec_copy = strdup(exec);
>  		if (!exec_copy) {
>  			ret = -ENOMEM;
> @@ -2352,14 +2360,15 @@ 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) * MAX_ADDRNAME_LEN);
>  	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);
> -	ret = 0;
> +	ret = e_snprintf(pp->function, MAX_ADDRNAME_LEN, "0x%llx", vaddr);
> +	if (ret > 0)
> +		ret = 0;
>  
>  out:
>  	if (map) {
> 


-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



      reply	other threads:[~2012-10-18  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18  1:17 [PATCH v2] perf probe: convert_name_to_addr() allocated the wrong size buffers for names Hyeoncheol Lee
2012-10-18  8:31 ` Masami Hiramatsu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=507FBE50.1060603@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=acme@ghostprotocols.net \
    --cc=hyc.lee@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=yrl.pp-manager.tt@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.