]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
perf tools: Fix raw sample reading
authorJiri Olsa <jolsa@redhat.com>
Thu, 29 Sep 2011 15:05:08 +0000 (17:05 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 29 Sep 2011 19:29:53 +0000 (16:29 -0300)
Wrong pointer is being passed for raw data sanity checking, when parsing
sample event.

This ends up with invalid event and perf record being stuck in
__perf_session__process_events function during processing build IDs
(process_buildids function).

Following command hangs up in my setup:
./perf record -e raw_syscalls:sys_enter ls

The fix is to use proper pointer to the raw data instead of the 'u'
union.

Reviewed-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1317308709-9474-2-git-send-email-jolsa@redhat.com
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c

index c5748c52318fdf34e441fbcdf65dc418565f68e2..e389815078d3477412c577b2c4938865f6284027 100644 (file)
@@ -449,6 +449,8 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
        }
 
        if (type & PERF_SAMPLE_RAW) {
+               const u64 *pdata;
+
                u.val64 = *array;
                if (WARN_ONCE(swapped,
                              "Endianness of raw data not corrected!\n")) {
@@ -462,11 +464,12 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
                        return -EFAULT;
 
                data->raw_size = u.val32[0];
+               pdata = (void *) array + sizeof(u32);
 
-               if (sample_overlap(event, &u.val32[1], data->raw_size))
+               if (sample_overlap(event, pdata, data->raw_size))
                        return -EFAULT;
 
-               data->raw_data = &u.val32[1];
+               data->raw_data = (void *) pdata;
        }
 
        return 0;