Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1493058

Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory

From Jann Horn <jann@thejh.net>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory
Date 2016-09-29 01:50 +0200
Message-ID <smwLU-4W8-3@gated-at.bofh.it> (permalink)
References <smvZv-4rb-9@gated-at.bofh.it> <smvZv-4rb-7@gated-at.bofh.it> <smwsx-4PC-7@gated-at.bofh.it> <smwCe-4SR-33@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Sep 29, 2016 at 01:32:56AM +0200, Jann Horn wrote:
> On Wed, Sep 28, 2016 at 04:22:53PM -0700, Andy Lutomirski wrote:
> > On Wed, Sep 28, 2016 at 3:54 PM, Jann Horn <jann@thejh.net> wrote:
> > > SELinux attempts to make it possible to whitelist trustworthy sources of
> > > code that may be mapped into memory, and Android makes use of this feature.
> > > To prevent an attacker from bypassing this by modifying R+X memory through
> > > /proc/$pid/mem or PTRACE_POKETEXT, it is necessary to call a security hook
> > > in check_vma_flags().
> > 
> > If selinux policy allows PTRACE_POKETEXT, is it really so bad for that
> > to result in code execution?
> 
> Have a look at __ptrace_may_access():
> 
> 	/* Don't let security modules deny introspection */
> 	if (same_thread_group(task, current))
> 		return 0;
> 
> This means thread A can attach to thread B and poke its memory, and SELinux
> can't do anything about it.
> 
> I guess another perspective on this would be that it's a problem that
> interfaces usable for poking user memory are subject to introspection rules
> (as opposed to e.g. /proc/self/maps, where it is actually useful).

Ugh, I'm talking nonsense, ptrace() doesn't work on threads. (/proc/$pid/mem
works though). And then, ptrace-ish APIs aside, there are those weird
devices that do DMA with force=1.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/3] fix SELinux W^X bypass via ptrace Jann Horn <jann@thejh.net> - 2016-09-29 01:00 +0200
  [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-09-29 01:00 +0200
    Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Andy Lutomirski <luto@amacapital.net> - 2016-09-29 01:30 +0200
      Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-09-29 01:40 +0200
        Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-09-29 01:50 +0200
    Re: [PATCH v2 2/3] mm: add LSM hook for writes to readonly memory Ingo Molnar <mingo@kernel.org> - 2016-09-29 08:30 +0200
  [PATCH v2 1/3] fs/exec: don't force writing memory access Jann Horn <jann@thejh.net> - 2016-09-29 01:00 +0200
    Re: [PATCH v2 1/3] fs/exec: don't force writing memory access Oleg Nesterov <oleg@redhat.com> - 2016-09-29 18:20 +0200
  [PATCH v2 3/3] selinux: require EXECMEM for forced ptrace poke Jann Horn <jann@thejh.net> - 2016-09-29 01:00 +0200
    Re: [PATCH v2 3/3] selinux: require EXECMEM for forced ptrace poke Ingo Molnar <mingo@kernel.org> - 2016-09-29 08:20 +0200
    Re: [PATCH v2 3/3] selinux: require EXECMEM for forced ptrace poke Stephen Smalley <sds@tycho.nsa.gov> - 2016-09-29 18:50 +0200

csiph-web