[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200608024925.42510-1-bobo.shaobowang@huawei.com>
Date: Mon, 8 Jun 2020 10:49:25 +0800
From: Wang ShaoBo <bobo.shaobowang@...wei.com>
To: unlisted-recipients:; (no To-header on input)
CC: <huawei.libin@...wei.com>, <cj.chengjian@...wei.com>,
<xiexiuqi@...wei.com>, <mark.rutland@....com>, <hch@...radead.org>,
<wcohen@...hat.com>, <linux-kernel@...r.kernel.org>,
<mtk.manpages@...il.com>, <wezhang@...hat.com>,
<gregkh@...uxfoundation.org>, <catalin.marinas@....com>,
<bobo.shaobowang@...wei.com>
Subject: [RESEND PATCH] sys_personality: Add optional arch hook arch_check_personality
Currently arm64 personality syscall uses wrapper __arm64_sys_personality
to redirect to __arm64_sys_arm64_personality, it's easily confused,
Whereas using an normal hook arch_check_personality() can reject
additional settings like this for special case of different architectures.
This makes code clean and easier for subsequent modification.
Signed-off-by: Wang ShaoBo <bobo.shaobowang@...wei.com>
Reviewed-by: Dominik Brodowski <linux@...inikbrodowski.net>
---
arch/arm64/kernel/sys.c | 7 +++----
include/linux/syscalls.h | 10 ----------
kernel/exec_domain.c | 14 +++++++++++++-
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index d5ffaaab31a7..5c01816d7a77 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -28,12 +28,13 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
}
-SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
+int arch_check_personality(unsigned int personality)
{
if (personality(personality) == PER_LINUX32 &&
!system_supports_32bit_el0())
return -EINVAL;
- return ksys_personality(personality);
+
+ return 0;
}
asmlinkage long sys_ni_syscall(void);
@@ -46,8 +47,6 @@ asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused)
/*
* Wrappers to pass the pt_regs argument.
*/
-#define __arm64_sys_personality __arm64_sys_arm64_personality
-
#undef __SYSCALL
#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *);
#include <asm/unistd.h>
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 1815065d52f3..3dbbad498027 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1393,16 +1393,6 @@ 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;
-}
-
/* for __ARCH_WANT_SYS_IPC */
long ksys_semtimedop(int semid, struct sembuf __user *tsops,
unsigned int nsops,
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 33f07c5f2515..f3682f4bf205 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -35,9 +35,21 @@ static int __init proc_execdomains_init(void)
module_init(proc_execdomains_init);
#endif
+int __weak arch_check_personality(unsigned int personality)
+{
+ return 0;
+}
+
SYSCALL_DEFINE1(personality, unsigned int, personality)
{
- unsigned int old = current->personality;
+ int err;
+ unsigned int old;
+
+ err = arch_check_personality(personality);
+ if (err)
+ return err;
+
+ old = current->personality;
if (personality != 0xffffffff)
set_personality(personality);
--
2.17.1
Powered by blists - more mailing lists