linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, will.deacon@arm.com,
	catalin.marinas@arm.com
Cc: Mark Rutland <mark.rutland@arm.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Dave Martin <dave.martin@arm.com>,
	Dominik Brodowski <linux@dominikbrodowski.net>
Subject: [PATCHv2 13/19] kernel: add ksys_personality()
Date: Fri,  1 Jun 2018 12:24:35 +0100	[thread overview]
Message-ID: <20180601112441.37810-14-mark.rutland@arm.com> (raw)
In-Reply-To: <20180601112441.37810-1-mark.rutland@arm.com>

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@arm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dave Martin <dave.martin@arm.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
---
 include/linux/syscalls.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 70fcda1a9049..652e166deb64 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -79,6 +79,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
@@ -1268,4 +1269,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

  parent reply	other threads:[~2018-06-01 11:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 11:24 [PATCHv2 00/19] arm64: invoke syscalls with pt_regs Mark Rutland
2018-06-01 11:24 ` [PATCHv2 01/19] arm64: consistently use unsigned long for thread flags Mark Rutland
2018-06-01 11:24 ` [PATCHv2 02/19] arm64: move SCTLR_EL{1,2} assertions to <asm/sysreg.h> Mark Rutland
2018-06-14 16:44   ` Will Deacon
2018-06-01 11:24 ` [PATCHv2 03/19] arm64: introduce sysreg_clear_set() Mark Rutland
2018-06-01 11:24 ` [PATCHv2 04/19] arm64: kill config_sctlr_el1() Mark Rutland
2018-06-01 11:24 ` [PATCHv2 05/19] arm64: kill change_cpacr() Mark Rutland
2018-06-01 11:24 ` [PATCHv2 06/19] arm64: move sve_user_{enable,disable} to <asm/fpsimd.h> Mark Rutland
2018-06-01 11:24 ` [PATCHv2 07/19] arm64: remove sigreturn wrappers Mark Rutland
2018-06-01 11:24 ` [PATCHv2 08/19] arm64: convert raw syscall invocation to C Mark Rutland
2018-06-01 11:24 ` [PATCHv2 09/19] arm64: convert syscall trace logic " Mark Rutland
2018-06-01 11:24 ` [PATCHv2 10/19] arm64: convert native/compat syscall entry " Mark Rutland
2018-06-01 11:24 ` [PATCHv2 11/19] arm64: don't reload GPRs after apply_ssbd Mark Rutland
2018-06-01 14:41   ` Marc Zyngier
2018-06-01 11:24 ` [PATCHv2 12/19] arm64: zero GPRs upon entry from EL0 Mark Rutland
2018-06-01 11:24 ` Mark Rutland [this message]
2018-06-01 11:24 ` [PATCHv2 14/19] kernel: add kcompat_sys_{f,}statfs64() Mark Rutland
2018-06-01 11:24 ` [PATCHv2 15/19] arm64: remove in-kernel call to sys_personality() Mark Rutland
2018-06-01 11:24 ` [PATCHv2 16/19] arm64: use {COMPAT,}SYSCALL_DEFINE0 for sigreturn Mark Rutland
2018-06-01 11:24 ` [PATCHv2 17/19] arm64: use SYSCALL_DEFINE6() for mmap Mark Rutland
2018-06-01 11:24 ` [PATCHv2 18/19] arm64: convert compat wrappers to C Mark Rutland
2018-06-01 11:24 ` [PATCHv2 19/19] arm64: implement syscall wrappers Mark Rutland

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=20180601112441.37810-14-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=dave.martin@arm.com \
    --cc=hch@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).