mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Victor Kamensky <kamensky@cisco.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: David Daney <david.daney@cavium.com>,
	"manesoni@cisco.com" <manesoni@cisco.com>,
	"ananth@in.ibm.com" <ananth@in.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: [PATCH 2/4] MIPS Kprobes: Deny probes on ll/sc instructions
Date: Wed, 16 Nov 2011 09:39:32 -0800 (PST)	[thread overview]
Message-ID: <Pine.GSO.4.58.1111160847340.381@infra-view9.cisco.com> (raw)
In-Reply-To: <20111116121207.GA5079@linux-mips.org>

Hi Ralf,

Please see inline

On Wed, 16 Nov 2011, Ralf Baechle wrote:

> On Tue, Nov 08, 2011 at 03:26:42PM -0800, Victor Kamensky wrote:
>
> > > s/insturctions/instructions/
> > >
> > > Not only is it a bad idea, it will probably make them fail 100% of the time.
> > >
> > > It is also an equally bad idea to place a probe between any LL and SC
> > > instructions.  How do you prevent that?
> >
> > As per below code comment we don't prevent that. There is no way to do
> > that.
>
> Similar to the way that the addresses of loads and stores from userspace
> are recorded in a special section we could build a list of forbidden
> address range.
>
> Is it worth it?

Yes, probably it could be done this way. It would require to change all
places where ll/sc used. Infrastructure to look at those tables in kernel
and in all loaded modules will be required. Cost of check in kprobes layer
will go up as well, but probably on acceptable level.

In my personal opinion benefits it would bring will not worth the effort.

Couple more, hopefully relevant, notes:

- on kprobes CPU independent layer there is already __kprobes marker
  (attribute section) that could be used to mark function where kprobes
  insertion is not allowed. So one may use it, albeit on function level
  granularity, not code range.

- in my personal opinion all these checks have just practical meaning and
  practical limitations. For example current mips kprobes check whether
  instruction is in delay slot looks at previous 4 bytes to match jump or
  branch instruction pattern. It works and really helps in 99.99% of the
  cases but it will break in some exotic case where the instruction
  follows data (jump table for example) or padding that happens to match
  jump or branch instruction pattern. Or even if instruction follows jump
  and branch instruction, it could be jumped directly on it (i.e serve as
  branch delay slot in one case and regular instruction in another case).
  In all such obscure cases current delay slot instruction check would
  produce false positive. And it is perfectly fine, given practical
  consideration. I just bring this to illustrate my point that in this
  sort of situations, where we are trying to prevent API caller to shot
  himself/herself in the foot, we don't need to push to absolute
  solutions, just practical one.

Thanks,
Victor

>   Ralf
>

  reply	other threads:[~2011-11-16 17:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 17:03 [PATCH 0/4] MIPS Kprobes Maneesh Soni
2011-11-08 17:04 ` [PATCH 1/4] MIPS Kprobes: Fix OOPS in arch_prepare_kprobe() Maneesh Soni
2011-11-08 19:57   ` David Daney
2011-11-09  5:26     ` Maneesh Soni
2011-11-17 23:17   ` Ralf Baechle
2011-11-08 17:05 ` [PATCH 2/4] MIPS Kprobes: Deny probes on ll/sc instructions Maneesh Soni
2011-11-08 20:01   ` David Daney
2011-11-08 23:26     ` Victor Kamensky
2011-11-16 12:12       ` Ralf Baechle
2011-11-16 17:39         ` Victor Kamensky [this message]
2011-11-17 23:18   ` Ralf Baechle
2011-11-08 17:07 ` [PATCH 3/4] MIPS Kprobes: Refactoring Branch emulation Maneesh Soni
2011-11-17 23:18   ` Ralf Baechle
2011-11-08 17:08 ` [PATCH 4/4] MIPS Kprobes: Support branch instructions probing - v2 Maneesh Soni
2011-11-17 23:18   ` Ralf Baechle

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=Pine.GSO.4.58.1111160847340.381@infra-view9.cisco.com \
    --to=kamensky@cisco.com \
    --cc=ananth@in.ibm.com \
    --cc=david.daney@cavium.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=manesoni@cisco.com \
    --cc=ralf@linux-mips.org \
    /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®