perf probe: Fix probe_point buffer overrun
authorMasami Hiramatsu <mhiramat@redhat.com>
Fri, 12 Mar 2010 23:22:17 +0000 (18:22 -0500)
committerIngo Molnar <mingo@elte.hu>
Sat, 13 Mar 2010 07:32:22 +0000 (08:32 +0100)
Fix probe_point array-size overrun problem. In some cases (e.g.
inline function), one user-specified probe-point can be
translated to many probe address, and it overruns pre-defined
array-size. This also removes redundant MAX_PROBES macro
definition.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
Cc: <stable@kernel.org>
LKML-Reference: <20100312232217.2017.45017.stgit@localhost6.localdomain6>
[ Note that only root can create new probes. Eventually we should remove
  the MAX_PROBES limit, but that is a larger patch not eligible to
  perf/urgent treatment. ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-probe.c
tools/perf/util/probe-finder.c

index c30a33592340e4977c4d82cfb7dabd618370be2c..152d6c9b1fa4a07619c7cd3d11a7f45b7777a1ff 100644 (file)
@@ -47,7 +47,6 @@
 #include "util/probe-event.h"
 
 #define MAX_PATH_LEN 256
-#define MAX_PROBES 128
 
 /* Session management structure */
 static struct {
index 1e6c65ebbd80f6f1954ffec13715a21ab9f53ed2..f9cbbf18e6ca0a03bb71c601b27e28a23fd903cb 100644 (file)
@@ -455,6 +455,9 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
        /* *pf->fb_ops will be cached in libdw. Don't free it. */
        pf->fb_ops = NULL;
 
+       if (pp->found == MAX_PROBES)
+               die("Too many( > %d) probe point found.\n", MAX_PROBES);
+
        pp->probes[pp->found] = strdup(tmp);
        pp->found++;
 }