Skip to contentSkip to conversation

perf session: Fix infinite loop in __perf_session__process_events

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jan 11, 2011 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  3d03e2ea74103a50c23d6ab1906cf73399c0dafb
Gitweb:     http://git.kernel.org/tip/3d03e2ea74103a50c23d6ab1906cf73399c0dafb
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 10 Jan 2011 21:37:57 -0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 10 Jan 2011 22:23:08 -0200

perf session: Fix infinite loop in __perf_session__process_events

In this if statement:

        if (head + event->header.size >= mmap_size) {
                if (mmaps[map_idx]) {
                        munmap(mmaps[map_idx], mmap_size);
                        mmaps[map_idx] = NULL;
                }

                page_offset = page_size * (head / page_size);
                file_offset += page_offset;
                head -= page_offset;
                goto remap;
        }

With, for instance, these values:

head=2992
event->header.size=48
mmap_size=3040

We end up endlessly looping back to remap. Off by one.

Problem introduced in 55b4462.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Tom Zanussi <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/util/session.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/session.c +1 -1
index 6fb4694..313dac2 100644
@@ -1007,7 +1007,7 @@ more:
 	if (size == 0)
 		size = 8;
 
-	if (head + event->header.size >= mmap_size) {
+	if (head + event->header.size > mmap_size) {
 		if (mmaps[map_idx]) {
 			munmap(mmaps[map_idx], mmap_size);
 			mmaps[map_idx] = NULL;