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


Groups > linux.kernel > #1514446

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

From Jann Horn <jann@thejh.net>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] mm: add LSM hook for writes to readonly memory
Date 2016-11-03 11:40 +0100
Message-ID <sznB7-2Ga-13@gated-at.bofh.it> (permalink)
References <szgzE-6A7-5@gated-at.bofh.it> <szgzE-6A7-29@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, 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.

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


Thread

[PATCH 1/3] fs/exec: don't force writing memory access Jann Horn <jann@thejh.net> - 2016-11-03 04:10 +0100
  [PATCH 3/3] selinux: require EXECMEM for forced ptrace poke Jann Horn <jann@thejh.net> - 2016-11-03 04:10 +0100
  [PATCH v3 1/3] fs/exec: don't force writing memory access Jann Horn <jann@thejh.net> - 2016-11-03 04:10 +0100
    Re: [PATCH v3 1/3] fs/exec: don't force writing memory access Oleg Nesterov <oleg@redhat.com> - 2016-11-03 18:30 +0100
  [PATCH v3 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-11-03 04:10 +0100
    Re: [PATCH v3 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-11-03 04:20 +0100
  [PATCH 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-11-03 04:10 +0100
    Re: [PATCH 2/3] mm: add LSM hook for writes to readonly memory Jann Horn <jann@thejh.net> - 2016-11-03 11:40 +0100

csiph-web