lkml.org 
[lkml]   [2012]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 1/5] perf: Validate address in symbol__inc_addr_samples().
From

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@davemloft.net>
---
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


\
 
 \ /
  Last update: 2012-03-25 22:31    [from the cache]
©2003-2011 Jasper Spaans