mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@infradead.org>
Subject: Re: [PATCH 2/2] perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems
Date: Fri, 28 Aug 2015 12:40:10 +0300	[thread overview]
Message-ID: <87lhcvhhtx.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20150828053130.GC26741@gmail.com>

Ingo Molnar <mingo@kernel.org> writes:

> * Alexander Shishkin <alexander.shishkin@linux.intel.com> wrote:
>
>> BTS leaks kernel addresses even in userspace-only mode due to imprecise IP
>> sampling, so sometimes syscall entry points or page fault handler addresses
>> end up in a userspace trace.
>> 
>> Now, intel_bts driver exports trace data zero-copy, it does not scan through
>> it to filter out the kernel addresses and it's would be a O(n) job.
>> 
>> To work around this situation, this patch forbids the use of intel_bts
>> driver by unprivileged users with paranoid setting higher than 1, which
>> forbids kernel tracing.
>> 
>> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>> ---
>>  arch/x86/kernel/cpu/perf_event_intel_bts.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>> 
>> diff --git a/arch/x86/kernel/cpu/perf_event_intel_bts.c b/arch/x86/kernel/cpu/perf_event_intel_bts.c
>> index 80df16e020..4f6daff92d 100644
>> --- a/arch/x86/kernel/cpu/perf_event_intel_bts.c
>> +++ b/arch/x86/kernel/cpu/perf_event_intel_bts.c
>> @@ -495,6 +495,16 @@ static int bts_event_init(struct perf_event *event)
>>  	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
>> +	 * users on paranoid systems since it provides trace data
>> +	 * to the user in a zero-copy fashion.
>> +	 */
>> +	if (event->attr.exclude_kernel && perf_paranoid_kernel() &&
>> +	    !capable(CAP_SYS_ADMIN))
>> +		return -EACCES;
>
> I.e. it's disabled by default as well, with default paranoia settings?

Actually no, the kernel's default is 1, which allows kernel profiling
for unprivileged users. Distros might be more strict though.

Regards,
--
Alex

      reply	other threads:[~2015-08-28  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 15:13 [PATCH 0/2] perf/x86/intel: Work around BTS leaking kernel addresses Alexander Shishkin
2015-08-27 15:13 ` [PATCH 1/2] perf/x86/intel/ds: " Alexander Shishkin
2015-08-28  5:30   ` Ingo Molnar
2015-08-28  6:06     ` Alexander Shishkin
2015-08-27 15:13 ` [PATCH 2/2] perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems Alexander Shishkin
2015-08-28  5:31   ` Ingo Molnar
2015-08-28  9:40     ` Alexander Shishkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhcvhhtx.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®