• Jiri Olsa's avatar
    perf evlist: Fix perf_evlist__mmap_read event overflow · a65cb4b9
    Jiri Olsa authored
    The perf_evlist__mmap_read used 'union perf_event' as a placeholder for
    event crossing the mmap boundary.
    
    This is ok for sample shorter than ~PATH_MAX. However we could grow up
    to the maximum sample size which is 16 bits max.
    
    I hit this overflow issue when using 'perf top -G dwarf' which produces
    sample with the size around 8192 bytes.  We could configure any valid
    sample size here using: '-G dwarf,size'.
    
    Using array with sample max size instead for the event placeholder. Also
    adding another safe check for the dynamic size of the user stack.
    
    TODO: The 'struct perf_mmap' is quite big now, maybe we could use some
    lazy allocation for event_copy size.
    Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
    Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
    Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Link: http://lkml.kernel.org/r/1380721599-24285-1-git-send-email-jolsa@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    a65cb4b9
evsel.c 47.8 KB