[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180702110415.10465-14-mark.rutland@arm.com>
Date: Mon, 2 Jul 2018 12:04:09 +0100
From: Mark Rutland <mark.rutland@....com>
To: linux-arm-kernel@...ts.infradead.org, will.deacon@....com
Cc: linux-kernel@...r.kernel.org, catalin.marinas@....com,
dave.martin@....com, hch@...radead.org, james.morse@....com,
linux@...inikbrodowski.net, linux-fsdevel@...r.kernel.org,
marc.zyngier@....com, mark.rutland@....com, viro@...iv.linux.org.uk
Subject: [PATCHv4 13/19] kernel: add ksys_personality()
Using this helper allows us to avoid the in-kernel call to the
sys_personality() syscall. The ksys_ prefix denotes that this function
is meant as a drop-in replacement for the syscall. In particular, it
uses the same calling convention as sys_personality().
Since ksys_personality is trivial, it is implemented directly in
<linux/syscalls.h>, as we do for ksys_close() and friends.
This helper is necessary to enable conversion of arm64's syscall
handling to use pt_regs wrappers.
Signed-off-by: Mark Rutland <mark.rutland@....com>
Reviewed-by: Dominik Brodowski <linux@...inikbrodowski.net>
Cc: Al Viro <viro@...iv.linux.org.uk>
Cc: Christoph Hellwig <hch@...radead.org>
Cc: Dave Martin <dave.martin@....com>
---
include/linux/syscalls.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a368a68cb667..abfe12d8a9c5 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -80,6 +80,7 @@ union bpf_attr;
#include <linux/unistd.h>
#include <linux/quota.h>
#include <linux/key.h>
+#include <linux/personality.h>
#include <trace/syscall.h>
#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
@@ -1281,4 +1282,14 @@ static inline long ksys_truncate(const char __user *pathname, loff_t length)
return do_sys_truncate(pathname, length);
}
+static inline unsigned int ksys_personality(unsigned int personality)
+{
+ unsigned int old = current->personality;
+
+ if (personality != 0xffffffff)
+ set_personality(personality);
+
+ return old;
+}
+
#endif
--
2.11.0
Powered by blists - more mailing lists