public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] perf: Validate address in symbol__inc_addr_samples().
@ 2012-03-25 20:28 David Miller
  2012-03-27 14:15 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2012-03-25 20:28 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel


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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-27 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-25 20:28 [PATCH 1/5] perf: Validate address in symbol__inc_addr_samples() David Miller
2012-03-27 14:15 ` Arnaldo Carvalho de Melo
2012-03-27 18:36   ` Arnaldo Carvalho de Melo
2012-03-27 21:30   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox