From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbbH1JkP (ORCPT ); Fri, 28 Aug 2015 05:40:15 -0400 Received: from mga03.intel.com ([134.134.136.65]:57226 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbbH1JkN (ORCPT ); Fri, 28 Aug 2015 05:40:13 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,424,1437462000"; d="scan'208";a="777373396" From: Alexander Shishkin To: Ingo Molnar Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo Subject: Re: [PATCH 2/2] perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems In-Reply-To: <20150828053130.GC26741@gmail.com> References: <1440688422-27954-1-git-send-email-alexander.shishkin@linux.intel.com> <1440688422-27954-3-git-send-email-alexander.shishkin@linux.intel.com> <20150828053130.GC26741@gmail.com> User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Fri, 28 Aug 2015 12:40:10 +0300 Message-ID: <87lhcvhhtx.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ingo Molnar writes: > * Alexander Shishkin 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 >> --- >> 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