• Mathieu Poirier's avatar
    perf/core: Fix crash when using HW tracing kernel filters · 7f635ff1
    Mathieu Poirier authored
    In function perf_event_parse_addr_filter(), the path::dentry of each struct
    perf_addr_filter is left unassigned (as it should be) when the pattern
    being parsed is related to kernel space.  But in function
    perf_addr_filter_match() the same dentries are given to d_inode() where
    the value is not expected to be NULL, resulting in the following splat:
    
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000058
      pc : perf_event_mmap+0x2fc/0x5a0
      lr : perf_event_mmap+0x2c8/0x5a0
      Process uname (pid: 2860, stack limit = 0x000000001cbcca37)
      Call trace:
       perf_event_mmap+0x2fc/0x5a0
       mmap_region+0x124/0x570
       do_mmap+0x344/0x4f8
       vm_mmap_pgoff+0xe4/0x110
       vm_mmap+0x2c/0x40
       elf_map+0x60/0x108
       load_elf_binary+0x450/0x12c4
       search_binary_handler+0x90/0x290
       __do_execve_file.isra.13+0x6e4/0x858
       sys_execve+0x3c/0x50
       el0_svc_naked+0x30/0x34
    
    This patch is fixing the problem by introducing a new check in function
    perf_addr_filter_match() to see if the filter's dentry is NULL.
    Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Cc: acme@kernel.org
    Cc: miklos@szeredi.hu
    Cc: namhyung@kernel.org
    Cc: songliubraving@fb.com
    Fixes: 9511bce9 ("perf/core: Fix bad use of igrab()")
    Link: http://lkml.kernel.org/r/1531782831-1186-1-git-send-email-mathieu.poirier@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    7f635ff1
core.c 279 KB