public inbox for kernel-hardening@lists.openwall.com
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: kernel-hardening@lists.openwall.com
Subject: [kernel-hardening] PAX_MPROTECT mechanism
Date: Sat, 23 Jul 2011 13:35:43 +0400	[thread overview]
Message-ID: <20110723093543.GA3908@albatros> (raw)

Solar, all -

This is a summary of PAX_MPROTECT actions and limitations.

Solar, please review the scheme and say whether it should be
relaxed/restricted or whether it makes sense to push it upstream at all.


* Stack is created with cleared VM_MAYEXEC => cannot be made exec in future.

* mmap() with (VM_WRITE | VM_EXEC) flags are denied.  If
CONFIG_PAX_MPROTECT_COMPAT=y then VM_EXEC is just cleared.
(If clamav detects NX while mapping a page for JIT, it fallbacks to
interpreter based mode.  Other programs might not detect it :( )

* If mmap() doesn't define VM_EXEC then VM_MAYEXEC is cleared (the page cannot
be made exec in the future), otherwise VM_MAYWRITE is cleared.

* brk() pages are created with cleared VM_MAYEXEC even when personality
READ_IMPLIES_EXEC is set.

* After RELRO ELF section is altered, it clears VM_MAYWRITE on the section.


So, with there restrictions there are no WX pages and there are 2 ways to
introduce new code in the task vm:

1) mmap with VM_EXEC pre-created file with attacker's code.

2) execve attacker's / system binary.

As PaX documentation says, both should be denied with some sandboxing
mechanism like RBAC/SELinux/etc.


In PaX there restrictions can be disabled per binary.  To do it in the
mainline kernel the toolchain should be patched :)

I'm afraid of stack restriction - it contradicts GNU_STACK policy.  Also
if GNU_STACK is still handled, it should be fully handled in kernel as
userspace hasn't got power to re-enable X.  So, before pushing it
upstream GNU_STACK problem might be necessarily resolved.

Thanks,

-- 
Vasiliy

                 reply	other threads:[~2011-07-23  9:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20110723093543.GA3908@albatros \
    --to=segoon@openwall.com \
    --cc=kernel-hardening@lists.openwall.com \
    /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