diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-03-16 09:50:50 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-03-16 09:50:50 +0100 |
commit | 2b95bd7d58d368fe5dcbe6f4e494847ea082d89d (patch) | |
tree | 48c38d792f31f2fe10b26b03bdf1b10a82ca03a4 /arch/x86/include/asm/pkeys.h | |
parent | Merge tag 'perf-core-for-mingo-4.12-20170314' of git://git.kernel.org/pub/scm... (diff) | |
parent | Merge branch 'for-linus' of git://git.kernel.dk/linux-block (diff) | |
download | linux-2b95bd7d58d368fe5dcbe6f4e494847ea082d89d.tar.xz linux-2b95bd7d58d368fe5dcbe6f4e494847ea082d89d.zip |
Merge branch 'linus' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/include/asm/pkeys.h')
-rw-r--r-- | arch/x86/include/asm/pkeys.h | 15 |
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; |