Skip to content

Commit da9ec3d

Browse files
mrutland-armIngo Molnar
authored andcommitted
perf: Correctly handle failed perf_get_aux_event()
Vince reports a worrying issue: | so I was tracking down some odd behavior in the perf_fuzzer which turns | out to be because perf_even_open() sometimes returns 0 (indicating a file | descriptor of 0) even though as far as I can tell stdin is still open. ... and further the cause: | error is triggered if aux_sample_size has non-zero value. | | seems to be this line in kernel/events/core.c: | | if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) | goto err_locked; | | (note, err is never set) This seems to be a thinko in commit: ab43762 ("perf: Allow normal events to output AUX data") ... and we should probably return -EINVAL here, as this should only happen when the new event is mis-configured or does not have a compatible aux_event group leader. Fixes: ab43762 ("perf: Allow normal events to output AUX data") Reported-by: Vince Weaver <[email protected]> Signed-off-by: Mark Rutland <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Alexander Shishkin <[email protected]> Tested-by: Vince Weaver <[email protected]>
1 parent b9fb2de commit da9ec3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/events/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11465,8 +11465,10 @@ SYSCALL_DEFINE5(perf_event_open,
1146511465
}
1146611466
}
1146711467

11468-
if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader))
11468+
if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) {
11469+
err = -EINVAL;
1146911470
goto err_locked;
11471+
}
1147011472

1147111473
/*
1147211474
* Must be under the same ctx::mutex as perf_install_in_context(),

0 commit comments

Comments
 (0)