* [PATCH] perf/x86/intel/bts: Fix exclusive event reference leak
@ 2017-10-23 12:35 Alexander Shishkin
2017-10-24 12:48 ` [tip:perf/urgent] " tip-bot for Alexander Shishkin
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shishkin @ 2017-10-23 12:35 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar; +Cc: linux-kernel, Alexander Shishkin
Commit
d2878d642a4ed ("perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems")
adds a privilege check in the exactly wrong place in the event init path:
after the 'LBR exclusive' reference has been taken, and doesn't release it
in the case of insuffucient privileges. After this, nobody in the system
gets to use PT or LBR afterwards.
This patch moves the privilege check to where it should have been in the
first place.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: d2878d642a4ed ("perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems")
---
arch/x86/events/intel/bts.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index ce1dac7115c9..91bbf0a3f27e 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -555,9 +555,6 @@ static int bts_event_init(struct perf_event *event)
if (event->attr.type != bts_pmu.type)
return -ENOENT;
- if (x86_add_exclusive(x86_lbr_exclusive_bts))
- return -EBUSY;
-
/*
* BTS leaks kernel addresses even when CPL0 tracing is
* disabled, so disallow intel_bts driver for unprivileged
@@ -571,6 +568,9 @@ static int bts_event_init(struct perf_event *event)
!capable(CAP_SYS_ADMIN))
return -EACCES;
+ if (x86_add_exclusive(x86_lbr_exclusive_bts))
+ return -EBUSY;
+
ret = x86_reserve_hardware();
if (ret) {
x86_del_exclusive(x86_lbr_exclusive_bts);
--
2.14.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* [tip:perf/urgent] perf/x86/intel/bts: Fix exclusive event reference leak
2017-10-23 12:35 [PATCH] perf/x86/intel/bts: Fix exclusive event reference leak Alexander Shishkin
@ 2017-10-24 12:48 ` tip-bot for Alexander Shishkin
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Alexander Shishkin @ 2017-10-24 12:48 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, torvalds, peterz, tglx, alexander.shishkin, mingo,
linux-kernel, a.p.zijlstra
Commit-ID: 2eece390bf68ec8f733d7e4a3ba8a5ea350082ae
Gitweb: https://git.kernel.org/tip/2eece390bf68ec8f733d7e4a3ba8a5ea350082ae
Author: Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Mon, 23 Oct 2017 15:35:33 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 24 Oct 2017 13:19:27 +0200
perf/x86/intel/bts: Fix exclusive event reference leak
Commit:
d2878d642a4ed ("perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems")
... adds a privilege check in the exactly wrong place in the event init path:
after the 'LBR exclusive' reference has been taken, and doesn't release it
in the case of insufficient privileges. After this, nobody in the system
gets to use PT or LBR afterwards.
This patch moves the privilege check to where it should have been in the
first place.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: d2878d642a4ed ("perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems")
Link: http://lkml.kernel.org/r/20171023123533.16973-1-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/events/intel/bts.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 16076eb..141e07b 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -546,9 +546,6 @@ static int bts_event_init(struct perf_event *event)
if (event->attr.type != bts_pmu.type)
return -ENOENT;
- if (x86_add_exclusive(x86_lbr_exclusive_bts))
- return -EBUSY;
-
/*
* BTS leaks kernel addresses even when CPL0 tracing is
* disabled, so disallow intel_bts driver for unprivileged
@@ -562,6 +559,9 @@ static int bts_event_init(struct perf_event *event)
!capable(CAP_SYS_ADMIN))
return -EACCES;
+ if (x86_add_exclusive(x86_lbr_exclusive_bts))
+ return -EBUSY;
+
ret = x86_reserve_hardware();
if (ret) {
x86_del_exclusive(x86_lbr_exclusive_bts);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-24 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-23 12:35 [PATCH] perf/x86/intel/bts: Fix exclusive event reference leak Alexander Shishkin
2017-10-24 12:48 ` [tip:perf/urgent] " tip-bot for Alexander Shishkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.