linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [tip: perf/urgent] perf: Correctly handle failed perf_get_aux_event()
@ 2020-01-17 10:37 tip-bot2 for Mark Rutland
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Mark Rutland @ 2020-01-17 10:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Vince Weaver, Mark Rutland, Peter Zijlstra (Intel),
	Ingo Molnar, Alexander Shishkin, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     da9ec3d3dd0f1240a48920be063448a2242dbd90
Gitweb:        https://git.kernel.org/tip/da9ec3d3dd0f1240a48920be063448a2242dbd90
Author:        Mark Rutland <mark.rutland@arm.com>
AuthorDate:    Mon, 06 Jan 2020 12:03:39 
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 17 Jan 2020 11:32:44 +01:00

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:

  ab43762ef010967e ("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: ab43762ef010967e ("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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index a1f8bde..2173c23 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11465,8 +11465,10 @@ SYSCALL_DEFINE5(perf_event_open,
 		}
 	}
 
-	if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader))
+	if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) {
+		err = -EINVAL;
 		goto err_locked;
+	}
 
 	/*
 	 * Must be under the same ctx::mutex as perf_install_in_context(),

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip: perf/urgent] perf: Correctly handle failed perf_get_aux_event()
@ 2020-01-17 10:08 tip-bot2 for Mark Rutland
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Mark Rutland @ 2020-01-17 10:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Vince Weaver, Mark Rutland, Alexander Shishkin, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     2bef101686951c743a6c98ca68cc3b3193f1fb81
Gitweb:        https://git.kernel.org/tip/2bef101686951c743a6c98ca68cc3b3193f1fb81
Author:        Mark Rutland <mark.rutland@arm.com>
AuthorDate:    Mon, 06 Jan 2020 12:03:39 
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 17 Jan 2020 10:19:24 +01:00

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:

  ab43762ef010967e ("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: ab43762ef010967e ("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>
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Tested-by: Vince Weaver <vincent.weaver@maine.edu>
---
 kernel/events/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index a1f8bde..2173c23 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11465,8 +11465,10 @@ SYSCALL_DEFINE5(perf_event_open,
 		}
 	}
 
-	if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader))
+	if (perf_need_aux_event(event) && !perf_get_aux_event(event, group_leader)) {
+		err = -EINVAL;
 		goto err_locked;
+	}
 
 	/*
 	 * Must be under the same ctx::mutex as perf_install_in_context(),

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-17 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 10:37 [tip: perf/urgent] perf: Correctly handle failed perf_get_aux_event() tip-bot2 for Mark Rutland
  -- strict thread matches above, loose matches on Subject: below --
2020-01-17 10:08 tip-bot2 for Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).