perf: Fix the aux_output group inheritance fix
Alexander Shishkin
reviewerPATCH 1/1 perf: Fix the aux_output group inheritance fix
Commit
f733c6b508bc ("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.
Quoted 5 lines
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
Quoted 8 lines
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.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -12129,7 +12129,7 @@ static int inherit_group(struct perf_event *parent_event,if (IS_ERR (child_ctr))return PTR_ERR (child_ctr); -if (sub->aux_event == parent_event && +if (sub->aux_event == parent_event && child_ctr && !perf_get_aux_event (child_ctr, leader))return -EINVAL ; }
Signature · 1 line
2.24.0.rc1
Alexander Shishkin
reviewerQuoted 3 lines · Alexander Shishkin
Commit
f733c6b508bc("perf/core: Fix inheritance ofaux_outputgroups")
In case this one is falling through the cracks.
Regards,
--
Alex
[tip: perf/urgent] perf/aux: Fix the aux_output group inheritance fix
In reply to Alexander ShishkinThe following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 00496fe5e09e8c8bb115540e7e3470553cd07a5c Gitweb: https://git.kernel.org/tip/00496fe5e09e8c8bb115540e7e3470553cd07a5c Author: Alexander Shishkin <[email protected]> AuthorDate: Fri, 01 Nov 2019 17:12:48 +02:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 13 Nov 2019 08:16:40 +01:00
perf/aux: Fix the aux_output group inheritance fix
Commit
f733c6b508bc ("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:
Quoted 5 lines
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
Quoted 8 lines
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.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -11899,7 +11899,7 @@ static int inherit_group(struct perf_event *parent_event,if (IS_ERR (child_ctr))return PTR_ERR (child_ctr); -if (sub->aux_event == parent_event && +if (sub->aux_event == parent_event && child_ctr && !perf_get_aux_event (child_ctr, leader))return -EINVAL ; }