public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>,
	systemtap <systemtap@redhat.com>,
	DLE <dle-develop@lists.sourceforge.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Christoph Hellwig <hch@infradead.org>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Jim Keniston <jkenisto@us.ibm.com>,
	"Frank Ch. Eigler" <fche@redhat.com>
Subject: Re: [RFC PATCH tracing/kprobes 4/5] perf: Support perf kprobe command for kprobe-event setup helper
Date: Sat, 26 Sep 2009 04:52:00 -0400	[thread overview]
Message-ID: <1253955120.12145.2.camel@frodo> (raw)
In-Reply-To: <20090925191546.12939.75278.stgit@omoto>

On Fri, 2009-09-25 at 12:15 -0700, Masami Hiramatsu wrote:

> +
> +#define MAX_CMDLEN 256
> +
> +static int synthesize_probepoint(struct probe_point *pp)
> +{
> +	char *buf;
> +	int i, len, ret;
> +	pp->probes[0] = buf = (char *)calloc(MAX_CMDLEN, sizeof(char));
> +	len = snprintf(buf, MAX_CMDLEN, "%s+%d", pp->function, pp->offset);

What happens if func and offset is too big for MAX_CMDLEN?

> +	for (i = 0; i < pp->nr_args; i++) {

Can you have a case where pp->nr_args == 0?

> +		ret = snprintf(&buf[len], MAX_CMDLEN - len, " %s",
> +			       pp->args[i]);
> +		if (ret <= 0 || ret >= MAX_CMDLEN - len) {
> +			free(pp->probes[0]);
> +			return -E2BIG;
> +		}
> +		len += ret;
> +	}
> +	return pp->found = 1;
> +}
> +
> +int cmd_kprobe(int argc, const char **argv, const char *prefix __used)
> +{
> +	int i, j, fd, ret, need_dwarf = 0;
> +	struct probe_point *pp;
> +	char buf[MAX_CMDLEN];
> +
> +	argc = parse_options(argc, argv, options, kprobe_usage,
> +		PARSE_OPT_STOP_AT_NON_OPTION);
> +	if (argc || session.nr_probe == 0)
> +		usage_with_options(kprobe_usage, options);
> +
> +	/* Synthesize return probes */
> +	for (j = 0; j < session.nr_probe; j++) {
> +		if (session.events[j][0] != 'r') {
> +			need_dwarf = 1;
> +			continue;
> +		}
> +		ret = synthesize_probepoint(&session.probes[j]);
> +		if (ret < 0)
> +			semantic_error("probe point is too long.");

If we have no args but the func and offset is too big, then this does
not catch it. But this depends on if we can have no args.

-- Steve

> +	}
> +
> 


  reply	other threads:[~2009-09-26  8:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-25 19:14 [RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support Masami Hiramatsu
2009-09-25 19:14 ` [RFC PATCH tracing/kprobes 1/5] tracing/kprobes: Rename special variables syntax Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 2/5] tracing/kprobes: Avoid field name confliction Masami Hiramatsu
2009-09-28  2:20   ` Li Zefan
2009-09-28 16:52     ` Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 3/5] tracing/kprobes: Rename fixed field name Masami Hiramatsu
2009-09-25 19:15 ` [RFC PATCH tracing/kprobes 4/5] perf: Support perf kprobe command for kprobe-event setup helper Masami Hiramatsu
2009-09-26  8:52   ` Steven Rostedt [this message]
2009-09-28 16:51     ` Masami Hiramatsu
2009-09-25 19:16 ` [RFC PATCH tracing/kprobes 5/5] perf: kprobe command supports without libdwarf Masami Hiramatsu
2009-09-30  1:06 ` [RFC PATCH tracing/kprobes 0/5] tracing/kprobes, perf: perf kprobe support Masami Hiramatsu
2009-09-30 12:04   ` Ingo Molnar
2009-09-30 14:57     ` Arnaldo Carvalho de Melo

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=1253955120.12145.2.camel@frodo \
    --to=rostedt@goodmis.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=efault@gmx.de \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=jkenisto@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=systemtap@redhat.com \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox