From: Florian Weimer <fweimer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: pkey_alloc/pkey_free semantics
Date: Sun, 5 Nov 2017 12:39:05 +0100 [thread overview]
Message-ID: <53ca4117-3694-45ac-3433-c9d3456e096b@redhat.com> (raw)
I'm implementing the memory protection key interfaces for glibc and
noticed that the pkey_alloc manpage in particular is a bit removed from
reality.
Here's what I found:
The flags argument is reserved and currently must be zero.
The access_rights argument instructs the kernel to set the access rights
for the new key for the current thread only (!). It's a bitmask with
bits PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE.
So in essence, both arguments are not needed right now because the
access rights of the current thread for the new key could easily be
changed in user space.
To repeat, pkey_alloc affects the access rights of the current thread.
Other threads retain their existing access rights. The default rights
for the process apparently can be set with the init_pkru parameter on
recent kernels (I have not tried that).
The manpage mentions only the key leak related to pkey_mprotect
(pkey_free while a page still is still associated with that key). There
is another one which affects a pkey_alloc/pthread_create/pkey_free
sequence, where any created threads retain their access rights. I
raised this issue of key reuse in a recent thread (MPK: pkey_free and
key reuse), so perhaps there will be a way
Anyway, the important manpage fix for now would be to fix the
description of the flags and access_rights parameters.
Thanks,
Florian
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2017-11-05 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-05 11:39 Florian Weimer [this message]
[not found] ` <53ca4117-3694-45ac-3433-c9d3456e096b-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-07 14:04 ` pkey_alloc/pkey_free semantics Florian Weimer
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=53ca4117-3694-45ac-3433-c9d3456e096b@redhat.com \
--to=fweimer-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.