]> git.baikalelectronics.ru Git - kernel.git/commit
perf: Correctly handle failed perf_get_aux_event()
authorMark Rutland <mark.rutland@arm.com>
Mon, 6 Jan 2020 12:03:39 +0000 (12:03 +0000)
committerIngo Molnar <mingo@kernel.org>
Fri, 17 Jan 2020 10:32:44 +0000 (11:32 +0100)
commitb49a7a799f9ae55f78b6220996c9875900dbf98f
tree09fe4329cba1d724c2421453a2759eada042530e
parent8653ccacb50b82e0f8bc4aa46ecb03c6a95fdf2d
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:

  7639d74b469297a3 ("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: 7639d74b469297a3 ("perf: Allow normal events to output AUX data")
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
kernel/events/core.c