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


Groups > linux.kernel > #1291522

Re: [PATCH 31/32] x86, pkeys: execute-only support

From Kees Cook <keescook@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH 31/32] x86, pkeys: execute-only support
Date 2015-12-14 21:10 +0100
Message-ID <qFHBw-2sR-11@gated-at.bofh.it> (permalink)
References <qFGFr-1Ro-7@gated-at.bofh.it> <qFGFs-1Ro-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Dec 14, 2015 at 11:06 AM, Dave Hansen <dave@sr71.net> wrote:
>
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> Protection keys provide new page-based protection in hardware.
> But, they have an interesting attribute: they only affect data
> accesses and never affect instruction fetches.  That means that
> if we set up some memory which is set as "access-disabled" via
> protection keys, we can still execute from it.
>
> This patch uses protection keys to set up mappings to do just that.
> If a user calls:
>
>         mmap(..., PROT_EXEC);
> or
>         mprotect(ptr, sz, PROT_EXEC);
>
> (note PROT_EXEC-only without PROT_READ/WRITE), the kernel will
> notice this, and set a special protection key on the memory.  It
> also sets the appropriate bits in the Protection Keys User Rights
> (PKRU) register so that the memory becomes unreadable and
> unwritable.
>
> I haven't found any userspace that does this today.

To realistically take advantage of this, it sounds like the linker
would need to know to keep bss and data page-aligned away from text,
and then set text to PROT_EXEC only?

Do you have any example linker scripts for this?

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH 31/32] x86, pkeys: execute-only support Dave Hansen <dave@sr71.net> - 2015-12-14 20:10 +0100
  Re: [PATCH 31/32] x86, pkeys: execute-only support Kees Cook <keescook@google.com> - 2015-12-14 21:10 +0100
    Re: [PATCH 31/32] x86, pkeys: execute-only support Kees Cook <keescook@google.com> - 2015-12-15 00:40 +0100
    Re: [PATCH 31/32] x86, pkeys: execute-only support Dave Hansen <dave@sr71.net> - 2015-12-15 00:40 +0100
      Re: [PATCH 31/32] x86, pkeys: execute-only support Andy Lutomirski <luto@amacapital.net> - 2015-12-15 00:40 +0100
        Re: [PATCH 31/32] x86, pkeys: execute-only support Kees Cook <keescook@google.com> - 2015-12-15 00:50 +0100
        Re: [PATCH 31/32] x86, pkeys: execute-only support Dave Hansen <dave@sr71.net> - 2015-12-15 00:50 +0100
          Re: [PATCH 31/32] x86, pkeys: execute-only support Andy Lutomirski <luto@amacapital.net> - 2015-12-15 00:50 +0100
            Re: [PATCH 31/32] x86, pkeys: execute-only support Dave Hansen <dave@sr71.net> - 2015-12-15 01:30 +0100

csiph-web