public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jin, Yao" <yao.jin@linux.intel.com>
To: Kyle Huey <me@kylehuey.com>
Cc: acme@kernel.org, jolsa@kernel.org,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	open list <Linux-kernel@vger.kernel.org>,
	Vince Weaver <vincent.weaver@maine.edu>,
	Will Deacon <will.deacon@arm.com>,
	Stephane Eranian <eranian@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com,
	Robert O'Callahan <robert@ocallahan.org>
Subject: Re: [PATCH v1 0/2] perf: Drop leaked kernel samples
Date: Fri, 15 Jun 2018 13:11:46 +0800	[thread overview]
Message-ID: <1a442b37-7a97-86f0-11e3-58d940ecfbc9@linux.intel.com> (raw)
In-Reply-To: <CAP045Aq_FEc_pEeRL86uXbOLBeW7aPvTqtnaq+Mbi-2=vp2BNA@mail.gmail.com>



On 6/15/2018 11:35 AM, Kyle Huey wrote:
> I strongly object to this patch as written. As I said when I
> originally reported[0] the regression introduced by the previous
> version of this patch a year ago.
> 
> "It seems like this change should, at a bare minimum, be limited to
> counters that actually perform sampling of register state when the
> interrupt fires.  In our case, with the retired conditional branches
> counter restricted to counting userspace events only, it makes no
> difference that the PMU interrupt happened to be delivered in the
> kernel."
> 
> This means identifying which values of `perf_event_attr::sample_type`
> are security concerns (presumably PERF_SAMPLE_IP is, and
> PERF_SAMPLE_TIME is not, and someone needs to go through and decide on
> all of them) and filtering on those values for this new behavior.
> 
> And because rr sets its sample_type to 0, once you do that, the sysctl
> will not be necessary.
> 
> - Kyle
> 

Since rr sets sample_type to 0, the easiest way is to add checking like:

if (event->attr.sample_type) {
	if (event->attr.exclude_kernel && !user_mode(regs))
		return false;
}

So the rr doesn't need to be changed and for other use cases the leaked 
kernel samples will be dropped.

But I don't like this is because:

1. It's too specific for rr case.

2. If we create a new sample_type, e.g. PERF_SAMPLE_ALLOW_LEAKAGE, the 
code will be:

if !(event->attr.sample_type & PERF_SAMPLE_ALLOW_LEAKAGE) {
	if (event->attr.exclude_kernel && !user_mode(regs))
		return false;
}

But rr needs to add PERF_SAMPLE_ALLOW_LEAKAGE to sample_type since by 
default the bit is not set.

3. Sysctl is a more flexible way. It provides us with an option when we 
want to see if skid is existing, we can use sysctl to turn on that.

Thanks
Jin Yao


  reply	other threads:[~2018-06-15  5:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 10:03 [PATCH v1 0/2] perf: Drop leaked kernel samples Jin Yao
2018-06-15  3:35 ` Kyle Huey
2018-06-15  5:11   ` Jin, Yao [this message]
2018-06-15 17:16     ` Kyle Huey
2018-06-15 17:34       ` Robert O'Callahan
2018-06-16  0:50         ` Jin, Yao
2018-06-16  0:56           ` Kyle Huey
2018-06-16  1:18             ` Jin, Yao
2018-06-15  7:45 ` Peter Zijlstra
2018-06-15  8:01   ` Jin, Yao
2018-06-15  8:12     ` Peter Zijlstra
2018-06-15  8:24       ` Jin, Yao
2018-06-15 16:54       ` Stephane Eranian
2018-06-15 10:03 ` [PATCH v1 1/2] perf/core: Use sysctl to turn on/off dropping " Jin Yao
2018-06-15  5:59   ` Stephane Eranian
2018-06-15  7:15     ` Jin, Yao
2018-06-19 16:50       ` Stephane Eranian
2018-06-15  6:02   ` Stephane Eranian
2018-06-15  8:16     ` Peter Zijlstra
2018-06-15 13:31       ` Liang, Kan
2018-06-18 10:41         ` Peter Zijlstra
2018-06-15 11:36   ` Mark Rutland
2018-06-16  1:27     ` Linus Torvalds
2018-06-18 10:51       ` Peter Zijlstra
2018-06-18  6:55     ` Jin, Yao
2018-06-18 10:45       ` Peter Zijlstra
2018-06-19  1:39         ` Jin, Yao
2018-06-19  6:01           ` Mark Rutland
2018-06-15 10:03 ` [PATCH v1 2/2] perf Documentation: Introduce the sysctl perf_allow_sample_leakage Jin Yao

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=1a442b37-7a97-86f0-11e3-58d940ecfbc9@linux.intel.com \
    --to=yao.jin@linux.intel.com \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=me@kylehuey.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robert@ocallahan.org \
    --cc=vincent.weaver@maine.edu \
    --cc=will.deacon@arm.com \
    --cc=yao.jin@intel.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