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


Groups > linux.kernel > #1488326 > unrolled thread

[PATCH v5 3/6] x86/arch_prctl Add a new do_arch_prctl

Started byKyle Huey <me@kylehuey.com>
First post2016-09-21 21:00 +0200
Last post2016-09-23 00:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v5 3/6] x86/arch_prctl Add a new do_arch_prctl Kyle Huey <me@kylehuey.com> - 2016-09-21 21:00 +0200
    Re: [PATCH v5 3/6] x86/arch_prctl Add a new do_arch_prctl Andy Lutomirski <luto@amacapital.net> - 2016-09-23 00:20 +0200

#1488326 — [PATCH v5 3/6] x86/arch_prctl Add a new do_arch_prctl

FromKyle Huey <me@kylehuey.com>
Date2016-09-21 21:00 +0200
Subject[PATCH v5 3/6] x86/arch_prctl Add a new do_arch_prctl
Message-ID<sjUUq-4cs-23@gated-at.bofh.it>
Add a new do_arch_prctl 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..94a57cc 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(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 62c0b0e..97aa104 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -567,3 +567,8 @@ unsigned long get_wchan(struct task_struct *p)
 	} while (count++ < 16 && p->state != TASK_RUNNING);
 	return 0;
 }
+
+long do_arch_prctl(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 292ce48..5c60e2c 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -590,7 +590,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(current, code, arg2);
+
+	return ret;
 }
 
 unsigned long KSTK_ESP(struct task_struct *task)
-- 
2.9.3

[toc] | [next] | [standalone]


#1489615

FromAndy Lutomirski <luto@amacapital.net>
Date2016-09-23 00:20 +0200
Message-ID<skkvv-3IV-23@gated-at.bofh.it>
In reply to#1488326
On Wed, Sep 21, 2016 at 11:58 AM, Kyle Huey <me@kylehuey.com> wrote:
> Add a new do_arch_prctl 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..94a57cc 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(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 62c0b0e..97aa104 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -567,3 +567,8 @@ unsigned long get_wchan(struct task_struct *p)
>         } while (count++ < 16 && p->state != TASK_RUNNING);
>         return 0;
>  }
> +
> +long do_arch_prctl(struct task_struct *task, int code, unsigned long arg2)
> +{
> +       return -EINVAL;
> +}

This should be do_arch_prctl_common or similar to avoid confusion.

P.S. The subject should be "x86/arch_prctl: ...".

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web