• Alexander Shishkin's avatar
    perf/aux: Fix the aux_output group inheritance fix · 00496fe5
    Alexander Shishkin authored
    Commit
    
      f733c6b5 ("perf/core: Fix inheritance of aux_output groups")
    
    adds a NULL pointer dereference in case inherit_group() races with
    perf_release(), which causes the below crash:
    
     > BUG: kernel NULL pointer dereference, address: 000000000000010b
     > #PF: supervisor read access in kernel mode
     > #PF: error_code(0x0000) - not-present page
     > PGD 3b203b067 P4D 3b203b067 PUD 3b2040067 PMD 0
     > Oops: 0000 [#1] SMP KASAN
     > CPU: 0 PID: 315 Comm: exclusive-group Tainted: G B 5.4.0-rc3-00181-g72e1839403cb-dirty #878
     > RIP: 0010:perf_get_aux_event+0x86/0x270
     > Call Trace:
     >  ? __perf_read_group_add+0x3b0/0x3b0
     >  ? __kasan_check_write+0x14/0x20
     >  ? __perf_event_init_context+0x154/0x170
     >  inherit_task_group.isra.0.part.0+0x14b/0x170
     >  perf_event_init_task+0x296/0x4b0
    
    Fix this by skipping over events that are getting closed, in the
    inheritance path.
    Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Fixes: f733c6b5 ("perf/core: Fix inheritance of aux_output groups")
    Link: https://lkml.kernel.org/r/20191101151248.47327-1-alexander.shishkin@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    00496fe5
core.c 292 KB