From: Andy Lutomirski <luto@amacapital.net>
To: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Oleg Nesterov <oleg@redhat.com>,
Ingo Molnar <mingo@kernel.org>, Christoph Hellwig <hch@lst.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Brian Gerst <brgerst@gmail.com>, "H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: Rethinking sigcontext's xfeatures slightly for PKRU's benefit?
Date: Mon, 21 Dec 2015 14:52:40 -0800 [thread overview]
Message-ID: <CALCETrW26qunk5CatBXXsTL4oBPoQ05q9Rch=tkbnKJU8GjJug@mail.gmail.com> (raw)
In-Reply-To: <5678310D.2010104@linux.intel.com>
On Dec 22, 2015 2:04 AM, "Dave Hansen" <dave.hansen@linux.intel.com> wrote:
>
> On 12/18/2015 03:16 PM, Andy Lutomirski wrote:
> > Hrm. We might also want an option to change pkru and/or baseline_pkru
> > in all threads in the current mm. That's optional but it could be
> > handy. Maybe it would be as simple as having the allocate-a-pkey call
> > have an option to set an initial baseline value and an option to
> > propagate that initial value to pre-existing threads.
>
> Do you mean actively going in and changing PKRU in other threads? I
> fear that will be dangerous.
>
> IMNHO, whatever we do, I think we need to ensure that _raw_ PKRU calls
> are allowed (somehow). Raw in this case would mean a thread calling
> WRPKRU without a system call and without checking in with what any other
> threads are doing.
>
> Let's say baseline_pkru=0x004 (we're access-disabling PKEY[1] and using
> it for execute-only). Now, a thread is trying to do this:
>
> pkey2 = sys_pkey_alloc(); // now pkey2=2
> tmp = rdpkru(); // 0x004
> tmp |= 0x10; // set PKRU[2].AD=1
> wrpkru(tmp);
>
> While another thread does:
>
> pkey4 = pkey_alloc(); // pkey4=4
> sys_pkey_set(pkey4, ACCESS_DISABLE, SET_BASELINE_ALL_THREADS);
>
> Without some kind of locking, that's going to race. We could do all the
> locking in the kernel, but that requires that the kernel do all the PKRU
> writing, which I'd really like to avoid.
>
> I think the closest we can get reasonably is to have the kernel track
> the baseline_pkru and then allow userspace to query it in case userspace
> decides that thread needs to update its thread-local PKRU from the baseline.
Yeah, fair point. Let's skip the modify-other-threads thing.
Perhaps this is silly, but what if the default were changed to deny
reads and writes for unallocated keys? Is there a use case that
breaks?
--Andy
next prev parent reply other threads:[~2015-12-21 22:53 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-18 1:48 Rethinking sigcontext's xfeatures slightly for PKRU's benefit? Andy Lutomirski
2015-12-18 2:13 ` Dave Hansen
2015-12-18 2:32 ` Andy Lutomirski
2015-12-18 2:52 ` Dave Hansen
2015-12-18 5:29 ` Andy Lutomirski
2015-12-18 6:43 ` H. Peter Anvin
2015-12-18 16:04 ` Andy Lutomirski
2015-12-18 16:56 ` Dave Hansen
2015-12-18 18:42 ` Dave Hansen
2015-12-18 19:21 ` Andy Lutomirski
2015-12-18 20:07 ` Dave Hansen
2015-12-18 20:28 ` Andy Lutomirski
2015-12-18 20:37 ` Linus Torvalds
2015-12-18 20:49 ` Andy Lutomirski
2015-12-18 20:58 ` H. Peter Anvin
2015-12-18 21:02 ` Andy Lutomirski
2015-12-18 21:08 ` Dave Hansen
2015-12-18 21:04 ` Linus Torvalds
2015-12-18 21:09 ` Linus Torvalds
2015-12-18 21:12 ` Dave Hansen
2015-12-18 21:45 ` Linus Torvalds
2015-12-18 22:28 ` Andy Lutomirski
2015-12-18 23:08 ` Linus Torvalds
2015-12-18 23:16 ` Andy Lutomirski
2015-12-18 23:20 ` Linus Torvalds
2015-12-21 17:04 ` Dave Hansen
2015-12-21 22:52 ` Andy Lutomirski [this message]
2015-12-21 23:00 ` Dave Hansen
2015-12-21 23:02 ` Andy Lutomirski
2015-12-21 23:05 ` Dave Hansen
2015-12-21 23:04 ` Dave Hansen
2015-12-21 23:07 ` Andy Lutomirski
2016-06-30 17:36 ` Andy Lutomirski
2016-06-30 21:25 ` Dave Hansen
2016-07-01 16:30 ` Andy Lutomirski
2015-12-29 23:48 ` Dave Hansen
2015-12-18 8:32 ` Ingo Molnar
2015-12-18 8:59 ` Christoph Hellwig
2015-12-18 12:57 ` Borislav Petkov
2016-01-12 13:38 ` Ingo Molnar
2016-01-12 13:42 ` Christoph Hellwig
2016-01-13 10:48 ` Ingo Molnar
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='CALCETrW26qunk5CatBXXsTL4oBPoQ05q9Rch=tkbnKJU8GjJug@mail.gmail.com' \
--to=luto@amacapital.net \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=hch@lst.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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).