[PATCH 1/5] perf: Validate address in symbol__inc_addr_samples().

From: David Miller
Date: Sun Mar 25 2012 - 16:28:13 EST



If addr < sym->start then we are going to access past the end of the
h->addr[] array, since the offset calculated will be huge.

Trigger an assertion instead of randomly scribbling memory when this
situation occurs.

Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
---
tools/perf/util/annotate.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e5a462f..734a503 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -15,6 +15,7 @@
#include "debug.h"
#include "annotate.h"
#include <pthread.h>
+#include <assert.h>

const char *disassembler_style;

@@ -64,6 +65,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,

pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));

+ assert(addr >= sym->start);
if (addr >= sym->end)
return 0;

--
1.7.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/