summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/pkeys.h
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-04-07 01:35:03 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2017-04-07 01:35:03 +0200
commitfccfb9950836524d79260448fba6131f6b1d73c3 (patch)
treea6fef32e330852138d9e7bd12d7b3dd97c4360c3 /arch/x86/include/asm/pkeys.h
parentgeneric ...copy_..._user primitives (diff)
parentmm, page_alloc: Add missing check for memory holes (diff)
downloadlinux-fccfb9950836524d79260448fba6131f6b1d73c3.tar.xz
linux-fccfb9950836524d79260448fba6131f6b1d73c3.zip
Merge commit 'b4fb8f66f1ae2e167d06c12d018025a8d4d3ba7e' into uaccess.ia64
backmerge of mainline ia64 fix
Diffstat (limited to 'arch/x86/include/asm/pkeys.h')
-rw-r--r--arch/x86/include/asm/pkeys.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h
index 34684adb6899..b3b09b98896d 100644
--- a/arch/x86/include/asm/pkeys.h
+++ b/arch/x86/include/asm/pkeys.h
@@ -46,6 +46,15 @@ extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
static inline
bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
{
+ /*
+ * "Allocated" pkeys are those that have been returned
+ * from pkey_alloc(). pkey 0 is special, and never
+ * returned from pkey_alloc().
+ */
+ if (pkey <= 0)
+ return false;
+ if (pkey >= arch_max_pkey())
+ return false;
return mm_pkey_allocation_map(mm) & (1U << pkey);
}
@@ -82,12 +91,6 @@ int mm_pkey_alloc(struct mm_struct *mm)
static inline
int mm_pkey_free(struct mm_struct *mm, int pkey)
{
- /*
- * pkey 0 is special, always allocated and can never
- * be freed.
- */
- if (!pkey)
- return -EINVAL;
if (!mm_pkey_is_allocated(mm, pkey))
return -EINVAL;