public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <ak@linux.intel.com>,
	Milind Chabbi <chabbi.milind@gmail.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Hari Bathini <hbathini@linux.vnet.ibm.com>,
	Jin Yao <yao.jin@linux.intel.com>,
	Kan Liang <kan.liang@intel.com>,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	Oleg Nesterov <onestero@redhat.com>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 4/6] hw_breakpoint: Factor out __modify_user_hw_breakpoint function
Date: Mon, 27 Nov 2017 18:09:11 +0100	[thread overview]
Message-ID: <20171127170911.GA22026@krava> (raw)
In-Reply-To: <20171127164639.3ymnc6io3eae7n4c@hirez.programming.kicks-ass.net>

On Mon, Nov 27, 2017 at 05:46:39PM +0100, Peter Zijlstra wrote:
> On Mon, Nov 27, 2017 at 05:21:31PM +0100, Jiri Olsa wrote:
> > +static int __modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr)
> > +{
> > +	u64 old_addr = bp->attr.bp_addr;
> > +	u64 old_len  = bp->attr.bp_len;
> > +	int old_type = bp->attr.bp_type;
> > +	bool modify  = attr->bp_type != old_type;
> > +	int err = 0;
> > +
> > +	bp->attr.bp_addr = attr->bp_addr;
> > +	bp->attr.bp_type = attr->bp_type;
> > +	bp->attr.bp_len  = attr->bp_len;
> > +
> > +	err = validate_hw_breakpoint(bp);
> > +	if (!err && modify)
> > +		err = modify_bp_slot(bp, old_type);
> > +
> > +	if (err) {
> > +		bp->attr.bp_addr = old_addr;
> > +		bp->attr.bp_type = old_type;
> > +		bp->attr.bp_len  = old_len;
> > +		return err;
> > +	}
> > +
> > +	bp->attr.disabled = attr->disabled;
> > +	return 0;
> > +}
> 
> I think this function is failing to check if anything else in the attr
> changes.
> 
> For example, someone could have added PERF_SAMPLE_BRANCH_STACK. That's
> something you'll fail to create breakpoints with, but this modification
> would 'accept'.
> 

hum, I dont think so.. the only things you're allowed to change
are bp_addr, bp_type and bp_len.. we put new values in those
fields and keep the rest untouched.. apart from 'disabled' bit

jirka

  reply	other threads:[~2017-11-27 17:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 16:21 [PATCH 0/6] hw_breakpoint: Breakpoint modification fixes Jiri Olsa
2017-11-27 16:21 ` [PATCH 1/6] hw_breakpoint: Pass bp_type directly as find_slot_idx argument Jiri Olsa
2017-11-27 16:21 ` [PATCH 2/6] hw_breakpoint: Pass bp_type argument to __reserve_bp_slot|__release_bp_slot Jiri Olsa
2017-11-27 16:21 ` [PATCH 3/6] hw_breakpoint: Add modify_bp_slot function Jiri Olsa
2017-11-27 16:21 ` [PATCH 4/6] hw_breakpoint: Factor out __modify_user_hw_breakpoint function Jiri Olsa
2017-11-27 16:46   ` Peter Zijlstra
2017-11-27 17:09     ` Jiri Olsa [this message]
2017-11-27 17:12       ` Peter Zijlstra
2017-11-27 17:25         ` Jiri Olsa
2017-11-27 17:34           ` Peter Zijlstra
2017-11-27 21:20             ` Peter Zijlstra
2017-11-27 21:50               ` Milind Chabbi
2017-11-27 22:01                 ` Peter Zijlstra
2017-11-27 22:16                   ` Milind Chabbi
2017-11-27 22:25                   ` Jiri Olsa
2017-11-27 22:41                     ` Milind Chabbi
2017-11-27 23:07                   ` Andi Kleen
2017-11-27 23:31                     ` Milind Chabbi
2017-11-28 11:24                     ` Jiri Olsa
2017-11-27 16:21 ` [PATCH 5/6] perf/core: fast breakpoint modification via _IOC_MODIFY_ATTRIBUTES Jiri Olsa
2017-11-27 16:21 ` [PATCH 6/6] perf tests: Add breakpoint accounting/modify test Jiri Olsa

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=20171127170911.GA22026@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=chabbi.milind@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=namhyung@kernel.org \
    --cc=onestero@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=will.deacon@arm.com \
    --cc=yao.jin@linux.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