linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Extend arch_prctl (int, ...) to 5 arguments
@ 2020-08-28 12:16 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2020-08-28 12:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-api, Linus Torvalds

Extend x86 arch_prctl (int, ...) to 5 arguments so that more arguments
can be passed to the kernel in registers.  The initial usage is to support
shadow stack in Intel CET.  In the current glibc, there is no arch_prctl
wrapper for i386.  There are arch_prctl wrappers with 2 arguments for
x86-64 and x32.  Since the first user of the new arch_prctl extension is
the C library, there should be no issue with the extension.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 arch/x86/include/asm/proto.h |  3 ++-
 arch/x86/kernel/process.c    |  3 ++-
 arch/x86/kernel/process_32.c |  6 ++++--
 arch/x86/kernel/process_64.c | 13 +++++++++----
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 28996fe19301..98bcada76fac 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -36,6 +36,7 @@ void x86_report_nx(void);
 extern int reboot_force;
 
 long do_arch_prctl_common(struct task_struct *task, int option,
-			  unsigned long cpuid_enabled);
+			  unsigned long cpuid_enabled, unsigned long arg3,
+			  unsigned long arg4, unsigned long arg5);
 
 #endif /* _ASM_X86_PROTO_H */
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 994d8393f2f7..9f8bc3b9a495 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -972,7 +972,8 @@ unsigned long get_wchan(struct task_struct *p)
 }
 
 long do_arch_prctl_common(struct task_struct *task, int option,
-			  unsigned long cpuid_enabled)
+			  unsigned long cpuid_enabled, unsigned long arg3,
+			  unsigned long arg4, unsigned long arg5)
 {
 	switch (option) {
 	case ARCH_GET_CPUID:
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 4f2f54e1281c..bd8d9c61b092 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -221,7 +221,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 	return prev_p;
 }
 
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
+SYSCALL_DEFINE5(arch_prctl, int, option, unsigned long, arg2,
+		unsigned long, arg3, unsigned long, arg4,
+		unsigned long, arg5)
 {
-	return do_arch_prctl_common(current, option, arg2);
+	return do_arch_prctl_common(current, option, arg2, arg3, arg4, arg5);
 }
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 9afefe325acb..6441aa912561 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -815,21 +815,26 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 	return ret;
 }
 
-SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
+SYSCALL_DEFINE5(arch_prctl, int, option, unsigned long, arg2,
+		unsigned long, arg3, unsigned long, arg4,
+		unsigned long, arg5)
 {
 	long ret;
 
 	ret = do_arch_prctl_64(current, option, arg2);
 	if (ret == -EINVAL)
-		ret = do_arch_prctl_common(current, option, arg2);
+		ret = do_arch_prctl_common(current, option, arg2, arg3, arg4,
+					   arg5);
 
 	return ret;
 }
 
 #ifdef CONFIG_IA32_EMULATION
-COMPAT_SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
+COMPAT_SYSCALL_DEFINE5(arch_prctl, int, option, unsigned long, arg2,
+		       unsigned long, arg3, unsigned long, arg4,
+		       unsigned long, arg5)
 {
-	return do_arch_prctl_common(current, option, arg2);
+	return do_arch_prctl_common(current, option, arg2, arg3, arg4, arg5);
 }
 #endif
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-28 12:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 12:16 [PATCH] x86: Extend arch_prctl (int, ...) to 5 arguments H.J. Lu

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