linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jann Horn <jann@thejh.net>
To: security@kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>,
	Paul Moore <paul@paul-moore.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Eric Paris <eparis@parisplace.org>,
	James Morris <james.l.morris@oracle.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	mchong@google.com, Andy Lutomirski <luto@amacapital.net>,
	Ingo Molnar <mingo@kernel.org>, Oleg Nesterov <oleg@redhat.com>,
	Nick Kralevich <nnk@google.com>,
	Janis Danisevskis <jdanis@google.com>
Cc: linux-security-module@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mm: add LSM hook for writes to readonly memory
Date: Thu, 3 Nov 2016 11:39:23 +0100	[thread overview]
Message-ID: <20161103103922.GD13748@pc.thejh.net> (raw)
In-Reply-To: <1478142286-18427-2-git-send-email-jann@thejh.net>

[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]

On Thu, Nov 03, 2016 at 04:04:42AM +0100, Jann Horn 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, PTRACE_POKETEXT or DMA, it is necessary to call a security
> hook in check_vma_flags().
> 
> PTRACE_POKETEXT can also be mitigated by blocking ptrace access, and
> /proc/$pid/mem can also be blocked at the VFS layer, but DMA is harder to
> deal with: Some driver functions (e.g. videobuf_dma_init_user_locked)
> write to user-specified DMA mappings even if those mappings are readonly
> or R+X.
> 
> The new security hook security_forced_write() takes three arguments:
> 
>  - The modified VMA, so the security check can e.g. test for executability.
>  - The subject performing the access. For remote accesses, this may be
>    different from the target of the access. This can e.g. be used to create
>    a security policy that permits a privileged debugger to set software
>    breakpoints in the address space of a sandboxed process.
>  - The target of the access. This is useful if only a subset of the
>    processes on the system should be prevented from executing arbitrary
>    code, as is the case on Android.
> 
> changed in v2:
>  - fix comment (Janis Danisevsk)
>  - simplify code a bit (Janis Danisevsk)
> 
> changed in v3:
>  - rebase
>  - no need to pass in creds in populate_vma_page_range()
>  - reword check_vma_flags() comment (Ingo Molnar)
>  - use helper struct gup_creds (Ingo Molnar)

I introduced some bugs here again, as the kernel test robot points out.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-11-03 10:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03  3:04 [PATCH 1/3] fs/exec: don't force writing memory access Jann Horn
2016-11-03  3:04 ` [PATCH 2/3] mm: add LSM hook for writes to readonly memory Jann Horn
2016-11-03 10:39   ` Jann Horn [this message]
2016-11-03  3:04 ` [PATCH 3/3] selinux: require EXECMEM for forced ptrace poke Jann Horn
2016-11-03  3:04 ` [PATCH v3 1/3] fs/exec: don't force writing memory access Jann Horn
2016-11-03 18:24   ` Oleg Nesterov
2016-11-03  3:04 ` [PATCH v3 2/3] mm: add LSM hook for writes to readonly memory Jann Horn
2016-11-03  3:10   ` Jann Horn
2016-11-03  3:04 ` [PATCH v3 3/3] selinux: require EXECMEM for forced ptrace poke Jann Horn
2016-11-03 13:21   ` Stephen Smalley

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=20161103103922.GD13748@pc.thejh.net \
    --to=jann@thejh.net \
    --cc=eparis@parisplace.org \
    --cc=james.l.morris@oracle.com \
    --cc=jdanis@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mchong@google.com \
    --cc=mingo@kernel.org \
    --cc=nnk@google.com \
    --cc=oleg@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=sds@tycho.nsa.gov \
    --cc=security@kernel.org \
    --cc=serge@hallyn.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).