When an architecture does not select CONFIG_ARCH_HAS_PKEYS, the pkey_alloc syscall will return -ENOSPC for all (otherwise well-formed) requests, as the generic implementation of mm_pkey_alloc() returns -1. The other pkey syscalls perform some work before always failing, in a similar fashion. This implies the absence of keys, but otherwise functional pkey support. This is odd, since the architecture provides no such support. Instead, it would be preferable to indicate that the syscall is not implemented, since this is effectively the case. This patch updates the pkey_* syscalls to return -ENOSYS on architectures without pkey support. Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Russell King <rmk+kernel@xxxxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: linux-api@xxxxxxxxxxxxxxx Cc: linux-arch@xxxxxxxxxxxxxxx Cc: linux-mm@xxxxxxxxx Cc: torvalds@xxxxxxxxxxxxxxxxxxxx --- mm/mprotect.c | 9 +++++++++ 1 file changed, 9 insertions(+) Hi, In eyeballing some recent commits I spotted 6127d124ee4eb9c3 ("ARM: wire up new pkey syscalls"), and in looking into that, I realised that the common pkey code looks somewhat suspicious. Many architectures don't have user-modifiable pkey support, and for those, we perform some unnecessary work before returning unclear error codes. As the pkey went in this merge window, there's stil time to tighten that up. Thanks, Mark. diff --git a/mm/mprotect.c b/mm/mprotect.c index 1193652..cda3abf 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -487,6 +487,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, SYSCALL_DEFINE4(pkey_mprotect, unsigned long, start, size_t, len, unsigned long, prot, int, pkey) { + if (!IS_ENABLED(CONFIG_ARCH_HAS_PKEYS)) + return -ENOSYS; + return do_mprotect_pkey(start, len, prot, pkey); } @@ -495,6 +498,9 @@ SYSCALL_DEFINE2(pkey_alloc, unsigned long, flags, unsigned long, init_val) int pkey; int ret; + if (!IS_ENABLED(CONFIG_ARCH_HAS_PKEYS)) + return -ENOSYS; + /* No flags supported yet. */ if (flags) return -EINVAL; @@ -524,6 +530,9 @@ SYSCALL_DEFINE1(pkey_free, int, pkey) { int ret; + if (!IS_ENABLED(CONFIG_ARCH_HAS_PKEYS)) + return -ENOSYS; + down_write(¤t->mm->mmap_sem); ret = mm_pkey_free(current->mm, pkey); up_write(¤t->mm->mmap_sem); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html