Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1503501

[PATCH v7 3/6] x86/arch_prctl: Add do_arch_prctl_common

From Kyle Huey <me@kylehuey.com>
Newsgroups linux.kernel
Subject [PATCH v7 3/6] x86/arch_prctl: Add do_arch_prctl_common
Date 2016-10-19 04:10 +0200
Message-ID <stOul-2wo-11@gated-at.bofh.it> (permalink)
References <stOul-2wo-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add do_arch_prctl_common to handle arch_prctls that are not specific to 64
bits. Call it from the syscall entry point, but not any of the other
callsites in the kernel, which all want one of the existing 64 bit only
arch_prctls.

Signed-off-by: Kyle Huey <khuey@kylehuey.com>
---
 arch/x86/include/asm/proto.h | 1 +
 arch/x86/kernel/process.c    | 5 +++++
 arch/x86/kernel/process_64.c | 8 +++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 95c3e51..f72b551 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -30,6 +30,7 @@ void x86_report_nx(void);
 
 extern int reboot_force;
 
+long do_arch_prctl_common(struct task_struct *task, int code, unsigned long arg2);
 #ifdef CONFIG_X86_64
 long do_arch_prctl_64(struct task_struct *task, int code, unsigned long arg2);
 #endif
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 0888a87..d0126b2 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -584,3 +584,8 @@ unsigned long get_wchan(struct task_struct *p)
 	put_task_stack(p);
 	return ret;
 }
+
+long do_arch_prctl_common(struct task_struct *task, int code, unsigned long arg2)
+{
+	return -EINVAL;
+}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 611df20..bf75d26 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -617,7 +617,13 @@ long do_arch_prctl_64(struct task_struct *task, int code, unsigned long arg2)
 
 SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2)
 {
-	return do_arch_prctl_64(current, code, arg2);
+	long ret;
+
+	ret = do_arch_prctl_64(current, code, arg2);
+	if (ret == -EINVAL)
+		ret = do_arch_prctl_common(current, code, arg2);
+
+	return ret;
 }
 
 unsigned long KSTK_ESP(struct task_struct *task)
-- 
2.10.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 0/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID for controlling the CPUID instruction Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 5/6] x86/cpufeature: Detect CPUID faulting support Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 3/6] x86/arch_prctl: Add do_arch_prctl_common Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 1/6] x86/arch_prctl/64: Use SYSCALL_DEFINE2 to define sys_arch_prctl Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 4/6] x86/syscalls/32: Wire up arch_prctl on x86-32 Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 6/6] x86/arch_prctl: Add ARCH_[GET|SET]_CPUID Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  [PATCH v7 2/6] x86/arch_prctl/64: Rename do_arch_prctl to do_arch_prctl_64 Kyle Huey <me@kylehuey.com> - 2016-10-19 04:10 +0200
  Re: [PATCH v7 0/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID for  controlling the CPUID instruction Kyle Huey <me@kylehuey.com> - 2016-10-25 07:40 +0200
    Re: [PATCH v7 0/6] x86/arch_prctl Add ARCH_[GET|SET]_CPUID for  controlling the CPUID instruction Thomas Gleixner <tglx@linutronix.de> - 2016-10-25 19:00 +0200

csiph-web