Skip to content

Commit 2eece39

Browse files
virtuosoIngo Molnar
authored andcommitted
perf/x86/intel/bts: Fix exclusive event reference leak
Commit: d2878d6 ("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 <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: d2878d6 ("perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 6cff0a1 commit 2eece39

File tree

1 file changed

+3
-3
lines changed
  • arch/x86/events/intel

1 file changed

+3
-3
lines changed

arch/x86/events/intel/bts.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,6 @@ static int bts_event_init(struct perf_event *event)
546546
if (event->attr.type != bts_pmu.type)
547547
return -ENOENT;
548548

549-
if (x86_add_exclusive(x86_lbr_exclusive_bts))
550-
return -EBUSY;
551-
552549
/*
553550
* BTS leaks kernel addresses even when CPL0 tracing is
554551
* disabled, so disallow intel_bts driver for unprivileged
@@ -562,6 +559,9 @@ static int bts_event_init(struct perf_event *event)
562559
!capable(CAP_SYS_ADMIN))
563560
return -EACCES;
564561

562+
if (x86_add_exclusive(x86_lbr_exclusive_bts))
563+
return -EBUSY;
564+
565565
ret = x86_reserve_hardware();
566566
if (ret) {
567567
x86_del_exclusive(x86_lbr_exclusive_bts);

0 commit comments

Comments
 (0)