diff mbox series

[12/18] kernel: add ksys_personality()

Message ID 20180514094640.27569-13-mark.rutland@arm.com
State New
Headers show
Series arm64: invoke syscalls with pt_regs | expand

Commit Message

Mark Rutland May 14, 2018, 9:46 a.m. UTC
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().

This 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: Dominik Brodowski <linux@dominikbrodowski.net>
---
 include/linux/syscalls.h | 1 +
 kernel/exec_domain.c     | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.11.0

Comments

Dave Martin May 14, 2018, 11:08 a.m. UTC | #1
On Mon, May 14, 2018 at 10:46:34AM +0100, Mark Rutland wrote:
> 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().

> 

> This 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: Dominik Brodowski <linux@dominikbrodowski.net>


Reviewed-by: Dave Martin <Dave.Martin@arm.com>


> ---

>  include/linux/syscalls.h | 1 +

>  kernel/exec_domain.c     | 7 ++++++-

>  2 files changed, 7 insertions(+), 1 deletion(-)

> 

> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h

> index 70fcda1a9049..6723ea51ec99 100644

> --- a/include/linux/syscalls.h

> +++ b/include/linux/syscalls.h

> @@ -1148,6 +1148,7 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,

>  			      unsigned long prot, unsigned long flags,

>  			      unsigned long fd, unsigned long pgoff);

>  ssize_t ksys_readahead(int fd, loff_t offset, size_t count);

> +unsigned int ksys_personality(unsigned int personality);

>  

>  /*

>   * The following kernel syscall equivalents are just wrappers to fs-internal

> diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c

> index a5697119290e..4ba2b404cba2 100644

> --- a/kernel/exec_domain.c

> +++ b/kernel/exec_domain.c

> @@ -47,7 +47,7 @@ static int __init proc_execdomains_init(void)

>  module_init(proc_execdomains_init);

>  #endif

>  

> -SYSCALL_DEFINE1(personality, unsigned int, personality)

> +unsigned int ksys_personality(unsigned int personality)

>  {

>  	unsigned int old = current->personality;

>  

> @@ -56,3 +56,8 @@ SYSCALL_DEFINE1(personality, unsigned int, personality)

>  

>  	return old;

>  }

> +

> +SYSCALL_DEFINE1(personality, unsigned int, personality)

> +{

> +	return ksys_personality(personality);

> +}

> -- 

> 2.11.0

> 

> 

> _______________________________________________

> linux-arm-kernel mailing list

> linux-arm-kernel@lists.infradead.org

> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Christoph Hellwig May 14, 2018, 12:07 p.m. UTC | #2
On Mon, May 14, 2018 at 10:46:34AM +0100, Mark Rutland wrote:
> 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().

> 

> This is necessary to enable conversion of arm64's syscall handling to

> use pt_regs wrappers.


Plese just opencode the trivial sys_personality logic instead.
Mark Rutland May 15, 2018, 9:56 a.m. UTC | #3
On Mon, May 14, 2018 at 05:07:56AM -0700, Christoph Hellwig wrote:
> On Mon, May 14, 2018 at 10:46:34AM +0100, Mark Rutland wrote:

> > 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().

> > 

> > This is necessary to enable conversion of arm64's syscall handling to

> > use pt_regs wrappers.

> 

> Plese just opencode the trivial sys_personality logic instead.


Sure, I'll make that a static inline in <linux/syscalls.h> as with
ksys_close() and friends.

Thanks,
Mark.
diff mbox series

Patch

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 70fcda1a9049..6723ea51ec99 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1148,6 +1148,7 @@  unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
 			      unsigned long prot, unsigned long flags,
 			      unsigned long fd, unsigned long pgoff);
 ssize_t ksys_readahead(int fd, loff_t offset, size_t count);
+unsigned int ksys_personality(unsigned int personality);
 
 /*
  * The following kernel syscall equivalents are just wrappers to fs-internal
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index a5697119290e..4ba2b404cba2 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -47,7 +47,7 @@  static int __init proc_execdomains_init(void)
 module_init(proc_execdomains_init);
 #endif
 
-SYSCALL_DEFINE1(personality, unsigned int, personality)
+unsigned int ksys_personality(unsigned int personality)
 {
 	unsigned int old = current->personality;
 
@@ -56,3 +56,8 @@  SYSCALL_DEFINE1(personality, unsigned int, personality)
 
 	return old;
 }
+
+SYSCALL_DEFINE1(personality, unsigned int, personality)
+{
+	return ksys_personality(personality);
+}