mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: David Long <dave.long@linaro.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	Sandeepa Prabhu <sandeepa.s.prabhu@gmail.com>,
	William Cohen <wcohen@redhat.com>,
	Pratyush Anand <panand@redhat.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v3] arm64: Improve kprobes test for atomic sequence
Date: Tue, 13 Sep 2016 01:29:36 +0900	[thread overview]
Message-ID: <20160913012936.489d3dc7a0b5a9e0f0670745@kernel.org> (raw)
In-Reply-To: <57D60AA7.6010304@linaro.org>

On Sun, 11 Sep 2016 21:53:43 -0400
David Long <dave.long@linaro.org> wrote:

> On 09/10/2016 01:48 AM, Masami Hiramatsu wrote:
> > On Fri,  9 Sep 2016 15:26:09 -0400
> > David Long <dave.long@linaro.org> wrote:
> >
> >> From: "David A. Long" <dave.long@linaro.org>
> >>
> >> Kprobes searches backwards a finite number of instructions to determine if
> >> there is an attempt to probe a load/store exclusive sequence. It stops when
> >> it hits the maximum number of instructions or a load or store exclusive.
> >> However this means it can run up past the beginning of the function and
> >> start looking at literal constants. This has been shown to cause a false
> >> positive and blocks insertion of the probe. To fix this, further limit the
> >> backwards search to stop if it hits a symbol address from kallsyms. The
> >> presumption is that this is the entry point to this code (particularly for
> >> the common case of placing probes at the beginning of functions).
> >>
> >> This also improves efficiency by not searching code that is not part of the
> >> function. There may be some possibility that the label might not denote the
> >> entry path to the probed instruction but the likelihood seems low and this
> >> is just another example of how the kprobes user really needs to be
> >> careful about what they are doing.
> >
> > Of course user should be careful, but also, in such case, kernel can reject
> > to probe it.
> >
> 
> I'm not exactly sure what you mean.  I'm just saying when everything 
> goes right we still cannot promise perfection in detecting a probe 
> within an atomic sequence.  This patch will reject a probe that is after 
> a ldx and has no intervening kallsyms label (and assuming it's within 
> the defined maximum count of subsequent instructions).
> 

Hmm, what I meant was the below code.

> >> +	/*
> >> +	 * If there's a symbol defined in front of and near enough to
> >> +	 * the probe address assume it is the entry point to this
> >> +	 * code and use it to further limit how far back we search
> >> +	 * when determining if we're in an atomic sequence. If we could
> >> +	 * not find any symbol skip the atomic test altogether as we
> >> +	 * could otherwise end up searching irrelevant text/literals.
> >> +	 * KPROBES depends on KALLSYMS so this last case should never
> >> +	 * happen.
> >> +	 */
> >> +	if (kallsyms_lookup_size_offset((unsigned long) addr, &size, &offset)) {
> >> +		if (offset < (MAX_ATOMIC_CONTEXT_SIZE*sizeof(kprobe_opcode_t)))
> >> +			scan_end = addr - (offset / sizeof(kprobe_opcode_t));
> >> +		else
> >> +			scan_end = addr - MAX_ATOMIC_CONTEXT_SIZE;
> >
> >          } else
> >                 return INSN_REJECTED;
> >
> >    that is what I expected...

As you said above,

> >> +	 * KPROBES depends on KALLSYMS so this last case should never
> >> +	 * happen.

If it should never happen, it also would be better to reject it because
it is unexpected result.

Thank you,

-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2016-09-12 16:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 19:26 David Long
2016-09-10  5:48 ` Masami Hiramatsu
2016-09-12  1:53   ` David Long
2016-09-12 16:29     ` Masami Hiramatsu [this message]
2016-09-12 18:19       ` David Long

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=20160913012936.489d3dc7a0b5a9e0f0670745@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=dave.long@linaro.org \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=panand@redhat.com \
    --cc=sandeepa.s.prabhu@gmail.com \
    --cc=wcohen@redhat.com \
    --cc=will.deacon@arm.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

Powered by JetHome