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


Groups > linux.kernel > #1238480

Re: [PATCH 26/26] x86, pkeys: Documentation

From Dave Hansen <dave@sr71.net>
Newsgroups linux.kernel
Subject Re: [PATCH 26/26] x86, pkeys: Documentation
Date 2015-10-02 20:00 +0200
Message-ID <qfcMI-29a-23@gated-at.bofh.it> (permalink)
References (5 earlier) <qckdI-3Kz-5@gated-at.bofh.it> <qeK42-2oH-7@gated-at.bofh.it> <qeSNY-71t-25@gated-at.bofh.it> <qeSXD-7fI-5@gated-at.bofh.it> <qf20W-3Fm-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 10/01/2015 11:23 PM, Ingo Molnar wrote:
>> > Also, how do we do mprotect_pkey and say "don't change the key"?
> So if we start managing keys as a resource (i.e. alloc/free up to 16 of them), and 
> provide APIs for user-space to do all that, then user-space is not supposed to 
> touch keys it has not allocated for itself - just like it's not supposed to write 
> to fds it has not opened.

I like that.  It gives us at least a "soft" indicator to userspace about
what keys it should or shouldn't be using.

> Such an allocation method can still 'mess up', and if the kernel allocates a key 
> for its purposes it should not assume that user-space cannot change it, but at 
> least for non-buggy code there's no interaction and it would work out fine.

Yeah.  It also provides a clean interface so that future hardware could
enforce enforce kernel "ownership" of a key which could protect against
even buggy code.

So, we add a pair of syscalls,

	unsigned long sys_alloc_pkey(unsigned long flags??)
	unsigned long sys_free_pkey(unsigned long pkey)

keep the metadata in the mm, and then make sure that userspace allocated
it before it is allowed to do an mprotect_pkey() with it.

mprotect_pkey(add, flags, pkey)
{
	if (!(mm->pkeys_allocated & (1 << pkey))
		return -EINVAL;
}

That should be pretty easy to implement.  The only real overhead is the
16 bits we need to keep in the mm somewhere.
--
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

Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-09-24 12:00 +0200
  Re: [PATCH 26/26] x86, pkeys: Documentation Andy Lutomirski <luto@amacapital.net> - 2015-09-24 21:20 +0200
    Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-09-25 09:20 +0200
  Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-09-24 21:20 +0200
    Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-09-25 08:20 +0200
    Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-01 13:20 +0200
      Re: [PATCH 26/26] x86, pkeys: Documentation Kees Cook <keescook@google.com> - 2015-10-01 22:40 +0200
        Re: [PATCH 26/26] x86, pkeys: Documentation Andy Lutomirski <luto@amacapital.net> - 2015-10-01 22:50 +0200
          Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-02 08:30 +0200
            Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-02 20:00 +0200
              Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-03 09:30 +0200
        Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-01 23:00 +0200
        Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-02 00:40 +0200
        Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-02 00:40 +0200
          Re: [PATCH 26/26] x86, pkeys: Documentation Kees Cook <keescook@google.com> - 2015-10-02 00:40 +0200
          Re: [PATCH 26/26] x86, pkeys: Documentation Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-02 00:50 +0200
            Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-02 01:00 +0200
              Re: [PATCH 26/26] x86, pkeys: Documentation Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-02 03:40 +0200
                Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-02 20:10 +0200
            Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-02 09:10 +0200
              Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-03 09:00 +0200
            Re: [PATCH 26/26] x86, pkeys: Documentation Paolo Bonzini <pbonzini@redhat.com> - 2015-10-02 13:50 +0200
              Re: [PATCH 26/26] x86, pkeys: Documentation Linus Torvalds <torvalds@linux-foundation.org> - 2015-10-02 14:00 +0200
                Re: [PATCH 26/26] x86, pkeys: Documentation Paolo Bonzini <pbonzini@redhat.com> - 2015-10-02 14:20 +0200
                Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-03 08:50 +0200
          Re: [PATCH 26/26] x86, pkeys: Documentation Andy Lutomirski <luto@amacapital.net> - 2015-10-02 01:00 +0200
          Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-02 08:10 +0200
  Re: [PATCH 26/26] x86, pkeys: Documentation Ingo Molnar <mingo@kernel.org> - 2015-10-03 10:20 +0200

csiph-web