All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@parisplace.org>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	James Morris <jmorris@namei.org>, Ingo Molnar <mingo@elte.hu>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linux-mm <linux-mm@kvack.org>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Christoph Hellwig <hch@infradead.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	SystemTap <systemtap@sources.redhat.com>,
	Jim Keniston <jkenisto@linux.vnet.ibm.com>,
	Roland McGrath <roland@hack.frob.com>,
	Andi Kleen <andi@firstfloor.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Eric Paris <eparis@redhat.com>,
	sds@tycho.nsa.gov
Subject: Re: [PATCH v3 2.6.39-rc1-tip 12/26] 12: uprobes: slot allocation for uprobes
Date: Wed, 20 Apr 2011 09:40:57 -0400	[thread overview]
Message-ID: <BANLkTimw7dV9_aSsrUfzwSdwr6UwZDsRwg@mail.gmail.com> (raw)
In-Reply-To: <20110419062654.GB10698@linux.vnet.ibm.com>

On Tue, Apr 19, 2011 at 2:26 AM, Srikar Dronamraju
<srikar@linux.vnet.ibm.com> wrote:
> * Peter Zijlstra <peterz@infradead.org> [2011-04-18 18:46:11]:
>
>> On Fri, 2011-04-01 at 20:04 +0530, Srikar Dronamraju wrote:

>> > +static int xol_add_vma(struct uprobes_xol_area *area)
>> > +{
>> > +   struct vm_area_struct *vma;
>> > +   struct mm_struct *mm;
>> > +   struct file *file;
>> > +   unsigned long addr;
>> > +   int ret = -ENOMEM;
>> > +
>> > +   mm = get_task_mm(current);
>> > +   if (!mm)
>> > +           return -ESRCH;
>> > +
>> > +   down_write(&mm->mmap_sem);
>> > +   if (mm->uprobes_xol_area) {
>> > +           ret = -EALREADY;
>> > +           goto fail;
>> > +   }
>> > +
>> > +   /*
>> > +    * Find the end of the top mapping and skip a page.
>> > +    * If there is no space for PAGE_SIZE above
>> > +    * that, mmap will ignore our address hint.
>> > +    *
>> > +    * We allocate a "fake" unlinked shmem file because
>> > +    * anonymous memory might not be granted execute
>> > +    * permission when the selinux security hooks have
>> > +    * their way.
>> > +    */
>>
>> That just annoys me, so we're working around some stupid sekurity crap,
>> executable anonymous maps are perfectly fine, also what do JITs do?
>
> Yes, we are working around selinux security hooks, but do we have a
> choice.
>
> James can you please comment on this.

[added myself and stephen, the 2 SELinux maintainers]

This is just wrong.  Anything to 'work around' SELinux in the kernel
is wrong.  SELinux access decisions are determined by policy not by
dirty hacks in the code to subvert any kind of security claims that
policy might hope to enforce.

[side note, security_file_mmap() is the right call if there is a file
or not.  It should just be called security_mmap() but the _file_ has
been around a long time and just never had a need to be changed]

Now how to fix the problems you were seeing.  If you run a modern
system with a GUI I'm willing to bet the pop-up window told you
exactly how to fix your problem.  If you are not on a GUI I accept
it's a more difficult as you most likely don't have the setroubleshoot
tools installed to help you out.  I'm just guess what your problem
was, but I think you have two solutions either:

1) chcon -t unconfined_execmem_t /path/to/your/binary
2) setsebool -P allow_execmem 1

The first will cause the binary to execute in a domain with
permissions to execute anonymous memory, the second will allow all
unconfined domains to execute anonymous memory.

I believe there was a question about how JIT's work with SELinux
systems.  They work mostly by method #1.

I did hear this question though: On a different but related note, how
is the use of uprobes controlled? Does it apply the same checking as
for ptrace?

Thanks guys!  If you have SELinux or LSM problems in the future let me
know.  It's likely the solution is easier than you imagine   ;)

-Eric

WARNING: multiple messages have this Message-ID (diff)
From: Eric Paris <eparis@parisplace.org>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	James Morris <jmorris@namei.org>, Ingo Molnar <mingo@elte.hu>,
	Steven Rostedt <rostedt@goodmis.org>,
	Linux-mm <linux-mm@kvack.org>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Christoph Hellwig <hch@infradead.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	SystemTap <systemtap@sources.redhat.com>,
	Jim Keniston <jkenisto@linux.vnet.ibm.com>,
	Roland McGrath <roland@hack.frob.com>,
	Andi Kleen <andi@firstfloor.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Eric Paris <eparis@redhat.com>,
	sds@tycho.nsa.gov
Subject: Re: [PATCH v3 2.6.39-rc1-tip 12/26] 12: uprobes: slot allocation for uprobes
Date: Wed, 20 Apr 2011 09:40:57 -0400	[thread overview]
Message-ID: <BANLkTimw7dV9_aSsrUfzwSdwr6UwZDsRwg@mail.gmail.com> (raw)
In-Reply-To: <20110419062654.GB10698@linux.vnet.ibm.com>

On Tue, Apr 19, 2011 at 2:26 AM, Srikar Dronamraju
<srikar@linux.vnet.ibm.com> wrote:
> * Peter Zijlstra <peterz@infradead.org> [2011-04-18 18:46:11]:
>
>> On Fri, 2011-04-01 at 20:04 +0530, Srikar Dronamraju wrote:

>> > +static int xol_add_vma(struct uprobes_xol_area *area)
>> > +{
>> > +   struct vm_area_struct *vma;
>> > +   struct mm_struct *mm;
>> > +   struct file *file;
>> > +   unsigned long addr;
>> > +   int ret = -ENOMEM;
>> > +
>> > +   mm = get_task_mm(current);
>> > +   if (!mm)
>> > +           return -ESRCH;
>> > +
>> > +   down_write(&mm->mmap_sem);
>> > +   if (mm->uprobes_xol_area) {
>> > +           ret = -EALREADY;
>> > +           goto fail;
>> > +   }
>> > +
>> > +   /*
>> > +    * Find the end of the top mapping and skip a page.
>> > +    * If there is no space for PAGE_SIZE above
>> > +    * that, mmap will ignore our address hint.
>> > +    *
>> > +    * We allocate a "fake" unlinked shmem file because
>> > +    * anonymous memory might not be granted execute
>> > +    * permission when the selinux security hooks have
>> > +    * their way.
>> > +    */
>>
>> That just annoys me, so we're working around some stupid sekurity crap,
>> executable anonymous maps are perfectly fine, also what do JITs do?
>
> Yes, we are working around selinux security hooks, but do we have a
> choice.
>
> James can you please comment on this.

[added myself and stephen, the 2 SELinux maintainers]

This is just wrong.  Anything to 'work around' SELinux in the kernel
is wrong.  SELinux access decisions are determined by policy not by
dirty hacks in the code to subvert any kind of security claims that
policy might hope to enforce.

[side note, security_file_mmap() is the right call if there is a file
or not.  It should just be called security_mmap() but the _file_ has
been around a long time and just never had a need to be changed]

Now how to fix the problems you were seeing.  If you run a modern
system with a GUI I'm willing to bet the pop-up window told you
exactly how to fix your problem.  If you are not on a GUI I accept
it's a more difficult as you most likely don't have the setroubleshoot
tools installed to help you out.  I'm just guess what your problem
was, but I think you have two solutions either:

1) chcon -t unconfined_execmem_t /path/to/your/binary
2) setsebool -P allow_execmem 1

The first will cause the binary to execute in a domain with
permissions to execute anonymous memory, the second will allow all
unconfined domains to execute anonymous memory.

I believe there was a question about how JIT's work with SELinux
systems.  They work mostly by method #1.

I did hear this question though: On a different but related note, how
is the use of uprobes controlled? Does it apply the same checking as
for ptrace?

Thanks guys!  If you have SELinux or LSM problems in the future let me
know.  It's likely the solution is easier than you imagine   ;)

-Eric

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-04-20 13:40 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-01 14:32 [PATCH v3 2.6.39-rc1-tip 0/26] 0: Uprobes patchset with perf probe support Srikar Dronamraju
2011-04-01 14:32 ` Srikar Dronamraju
2011-04-01 14:32 ` [PATCH v3 2.6.39-rc1-tip 1/26] 1: mm: replace_page() loses static attribute Srikar Dronamraju
2011-04-01 14:32   ` Srikar Dronamraju
2011-04-01 14:32 ` [PATCH v3 2.6.39-rc1-tip 2/26] 2: mm: Move replace_page() to mm/memory.c Srikar Dronamraju
2011-04-01 14:32   ` Srikar Dronamraju
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 3/26] 3: X86 specific breakpoint definitions Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 4/26] 4: uprobes: Breakground page replacement Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-18 12:20   ` Peter Zijlstra
2011-04-18 12:20     ` Peter Zijlstra
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 5/26] 5: uprobes: Adding and remove a uprobe in a rb tree Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-18 12:20   ` Peter Zijlstra
2011-04-18 12:20     ` Peter Zijlstra
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 6/26] 6: Uprobes: register/unregister probes Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-02  0:26   ` Stephen Wilson
2011-04-02  0:26     ` Stephen Wilson
2011-04-02  0:53     ` Srikar Dronamraju
2011-04-02  0:53       ` Srikar Dronamraju
2011-04-02  1:29       ` Stephen Wilson
2011-04-02  1:29         ` Stephen Wilson
2011-04-18 12:20   ` Peter Zijlstra
2011-04-18 12:20     ` Peter Zijlstra
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 7/26] 7: x86: analyze instruction and determine fixups Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-19 13:29   ` Steven Rostedt
2011-04-19 13:29     ` Steven Rostedt
2011-04-21 17:31     ` Srikar Dronamraju
2011-04-21 17:31       ` Srikar Dronamraju
2011-04-21 17:52       ` Peter Zijlstra
2011-04-21 17:52         ` Peter Zijlstra
2011-04-01 14:33 ` [PATCH v3 2.6.39-rc1-tip 8/26] 8: uprobes: store/restore original instruction Srikar Dronamraju
2011-04-01 14:33   ` Srikar Dronamraju
2011-04-18 16:12   ` Peter Zijlstra
2011-04-18 16:12     ` Peter Zijlstra
2011-04-01 14:34 ` [PATCH v3 2.6.39-rc1-tip 9/26] 9: uprobes: mmap and fork hooks Srikar Dronamraju
2011-04-01 14:34   ` Srikar Dronamraju
2011-04-18 16:21   ` Peter Zijlstra
2011-04-18 16:21     ` Peter Zijlstra
2011-04-18 16:29   ` Peter Zijlstra
2011-04-18 16:29     ` Peter Zijlstra
2011-04-19  6:45     ` Srikar Dronamraju
2011-04-19  6:45       ` Srikar Dronamraju
2011-04-01 14:34 ` [PATCH v3 2.6.39-rc1-tip 10/26] 10: x86: architecture specific task information Srikar Dronamraju
2011-04-01 14:34   ` Srikar Dronamraju
2011-04-01 14:34 ` [PATCH v3 2.6.39-rc1-tip 11/26] 11: uprobes: task specific information Srikar Dronamraju
2011-04-01 14:34   ` Srikar Dronamraju
2011-04-01 14:34 ` [PATCH v3 2.6.39-rc1-tip 12/26] 12: uprobes: slot allocation for uprobes Srikar Dronamraju
2011-04-01 14:34   ` Srikar Dronamraju
2011-04-18 16:46   ` Peter Zijlstra
2011-04-18 16:46     ` Peter Zijlstra
2011-04-19  6:26     ` Srikar Dronamraju
2011-04-19  6:26       ` Srikar Dronamraju
2011-04-19  9:02       ` Peter Zijlstra
2011-04-19  9:02         ` Peter Zijlstra
2011-04-19  9:11       ` Peter Zijlstra
2011-04-19  9:11         ` Peter Zijlstra
2011-04-20 13:40       ` Eric Paris [this message]
2011-04-20 13:40         ` Eric Paris
2011-04-20 14:51         ` Frank Ch. Eigler
2011-04-20 14:51           ` Frank Ch. Eigler
2011-04-20 15:16           ` Stephen Smalley
2011-04-20 15:16             ` Stephen Smalley
2011-04-21 14:11         ` Srikar Dronamraju
2011-04-21 14:11           ` Srikar Dronamraju
2011-04-21 14:45           ` Eric Paris
2011-04-21 14:45             ` Eric Paris
2011-04-21 16:14             ` Roland McGrath
2011-04-21 16:14               ` Roland McGrath
2011-04-21 16:59             ` Srikar Dronamraju
2011-04-21 16:59               ` Srikar Dronamraju
2011-04-01 14:35 ` [PATCH v3 2.6.39-rc1-tip 13/26] 13: uprobes: get the breakpoint address Srikar Dronamraju
2011-04-01 14:35   ` Srikar Dronamraju
2011-04-18 16:47   ` Peter Zijlstra
2011-04-18 16:47     ` Peter Zijlstra
2011-04-01 14:35 ` [PATCH v3 2.6.39-rc1-tip 14/26] 14: x86: x86 specific probe handling Srikar Dronamraju
2011-04-01 14:35   ` Srikar Dronamraju
2011-04-18 16:55   ` Peter Zijlstra
2011-04-18 16:55     ` Peter Zijlstra
2011-04-19  5:43     ` Srikar Dronamraju
2011-04-19  5:43       ` Srikar Dronamraju
2011-04-18 16:57   ` Peter Zijlstra
2011-04-18 16:57     ` Peter Zijlstra
2011-04-01 14:35 ` [PATCH v3 2.6.39-rc1-tip 15/26] 15: uprobes: Handing int3 and singlestep exception Srikar Dronamraju
2011-04-01 14:35   ` Srikar Dronamraju
2011-04-19 13:03   ` Peter Zijlstra
2011-04-19 13:03     ` Peter Zijlstra
2011-04-19 13:12     ` Steven Rostedt
2011-04-19 13:12       ` Steven Rostedt
2011-04-21 17:10     ` Srikar Dronamraju
2011-04-21 17:10       ` Srikar Dronamraju
2011-04-21 17:41       ` Peter Zijlstra
2011-04-21 17:41         ` Peter Zijlstra
2011-04-19 13:39   ` Peter Zijlstra
2011-04-19 13:39     ` Peter Zijlstra
2011-04-21 17:03     ` Srikar Dronamraju
2011-04-21 17:03       ` Srikar Dronamraju
2011-04-01 14:35 ` [PATCH v3 2.6.39-rc1-tip 16/26] 16: x86: uprobes exception notifier for x86 Srikar Dronamraju
2011-04-01 14:35   ` Srikar Dronamraju
2011-04-01 14:35 ` [PATCH v3 2.6.39-rc1-tip 17/26] 17: uprobes: register a notifier for uprobes Srikar Dronamraju
2011-04-01 14:35   ` Srikar Dronamraju
2011-04-19 13:54   ` Peter Zijlstra
2011-04-19 13:54     ` Peter Zijlstra
2011-04-01 14:36 ` [PATCH v3 2.6.39-rc1-tip 18/26] 18: uprobes: commonly used filters Srikar Dronamraju
2011-04-01 14:36   ` Srikar Dronamraju
2011-04-05  1:26   ` Masami Hiramatsu
2011-04-05  1:26     ` Masami Hiramatsu
2011-04-19 13:57   ` Peter Zijlstra
2011-04-19 13:57     ` Peter Zijlstra
2011-04-21 11:09     ` Srikar Dronamraju
2011-04-21 11:09       ` Srikar Dronamraju
2011-04-21 11:37       ` Peter Zijlstra
2011-04-21 11:37         ` Peter Zijlstra
2011-04-21 11:49         ` Srikar Dronamraju
2011-04-21 11:49           ` Srikar Dronamraju
2011-04-01 14:36 ` [PATCH v3 2.6.39-rc1-tip 19/26] 19: tracing: Extract out common code for kprobes/uprobes traceevents Srikar Dronamraju
2011-04-01 14:36   ` Srikar Dronamraju
2011-04-01 14:36 ` [PATCH v3 2.6.39-rc1-tip 20/26] 20: tracing: uprobes trace_event interface Srikar Dronamraju
2011-04-01 14:36   ` Srikar Dronamraju
2011-04-01 14:36 ` [PATCH v3 2.6.39-rc1-tip 21/26] 21: Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Srikar Dronamraju
2011-04-01 14:36   ` Srikar Dronamraju
2011-04-01 14:47   ` [RESEND] [PATCH v3 2.6.39-rc1-tip 21/26] 21: Uprobe tracer documentation " Srikar Dronamraju
2011-04-01 14:47     ` Srikar Dronamraju
2011-04-01 14:36 ` [PATCH v3 2.6.39-rc1-tip 22/26] 22: perf: rename target_module to target Srikar Dronamraju
2011-04-01 14:36   ` Srikar Dronamraju
2011-04-04 10:06   ` Masami Hiramatsu
2011-04-04 10:06     ` Masami Hiramatsu
2011-04-06 23:46     ` Srikar Dronamraju
2011-04-06 23:46       ` Srikar Dronamraju
2011-04-01 14:37 ` [PATCH v3 2.6.39-rc1-tip 23/26] 23: perf: show possible probes in a given executable file or library Srikar Dronamraju
2011-04-01 14:37   ` Srikar Dronamraju
2011-04-04 10:15   ` Masami Hiramatsu
2011-04-04 10:15     ` Masami Hiramatsu
2011-04-06 22:50     ` Srikar Dronamraju
2011-04-06 22:50       ` Srikar Dronamraju
2011-04-01 14:37 ` [PATCH v3 2.6.39-rc1-tip 24/26] 24: perf: perf interface for uprobes Srikar Dronamraju
2011-04-01 14:37   ` Srikar Dronamraju
2011-04-01 14:37 ` [PATCH v3 2.6.39-rc1-tip 25/26] 25: perf: Documentation for perf uprobes Srikar Dronamraju
2011-04-01 14:37   ` Srikar Dronamraju
2011-04-01 14:37 ` [PATCH v3 2.6.39-rc1-tip 26/26] 26: uprobes: filter chain Srikar Dronamraju
2011-04-01 14:37   ` Srikar Dronamraju
2011-04-05  1:27   ` Masami Hiramatsu
2011-04-05  1:27     ` Masami Hiramatsu
2011-04-06 22:41     ` Srikar Dronamraju
2011-04-06 22:41       ` Srikar Dronamraju
2011-04-07  3:19       ` Masami Hiramatsu
2011-04-07  3:19         ` Masami Hiramatsu

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=BANLkTimw7dV9_aSsrUfzwSdwr6UwZDsRwg@mail.gmail.com \
    --to=eparis@parisplace.org \
    --cc=acme@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=corbet@lwn.net \
    --cc=eparis@redhat.com \
    --cc=hch@infradead.org \
    --cc=jkenisto@linux.vnet.ibm.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=roland@hack.frob.com \
    --cc=rostedt@goodmis.org \
    --cc=sds@tycho.nsa.gov \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=systemtap@sources.redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.