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


Groups > linux.kernel > #1483806

Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32.

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32.
Date 2016-09-15 03:20 +0200
Message-ID <shtvj-dX-3@gated-at.bofh.it> (permalink)
References <shpBn-665-13@gated-at.bofh.it> <shpBo-665-45@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Sep 14, 2016 at 2:01 PM, Kyle Huey <me@kylehuey.com> wrote:
> Signed-off-by: Kyle Huey <khuey@kylehuey.com>
> ---
>  arch/x86/entry/syscalls/syscall_32.tbl |  1 +
>  arch/x86/kernel/process.c              | 80 ++++++++++++++++++++++++++++++++++
>  arch/x86/kernel/process_64.c           | 66 ----------------------------
>  3 files changed, 81 insertions(+), 66 deletions(-)
>
> diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
> index f848572..3b6965b 100644
> --- a/arch/x86/entry/syscalls/syscall_32.tbl
> +++ b/arch/x86/entry/syscalls/syscall_32.tbl
> @@ -386,3 +386,4 @@
>  377    i386    copy_file_range         sys_copy_file_range
>  378    i386    preadv2                 sys_preadv2                     compat_sys_preadv2
>  379    i386    pwritev2                sys_pwritev2                    compat_sys_pwritev2
> +380    i386    arch_prctl              sys_arch_prctl
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index 62c0b0e..0f857c3 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -20,6 +20,7 @@
>  #include <linux/cpuidle.h>
>  #include <trace/events/power.h>
>  #include <linux/hw_breakpoint.h>
> +#include <linux/syscalls.h>
>  #include <asm/cpu.h>
>  #include <asm/apic.h>
>  #include <asm/syscalls.h>
> @@ -32,6 +33,7 @@
>  #include <asm/tlbflush.h>
>  #include <asm/mce.h>
>  #include <asm/vm86.h>
> +#include <asm/prctl.h>
>
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
> @@ -567,3 +569,81 @@ 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)
> +{
> +       int ret = 0;
> +       int doit = task == current;
> +       int is_32 = IS_ENABLED(CONFIG_IA32_EMULATION) && test_thread_flag(TIF_IA32);

This should be in_compat_syscall().

Also, this code is sufficiently twisted that I think it would be
better to have a common function that handles common prctls and defers
to a 64-bit-specific function if needed, or vice versa.  Vice versa
might be easier -- have a do_arch_prctl_common() that is listed as the
compat entry and have the 64-bit entry call it for unhandled prctls.

--Andy

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


Thread

[PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Kyle Huey <me@kylehuey.com> - 2016-09-14 23:10 +0200
  Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-14 23:30 +0200
    Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Kyle Huey <me@kylehuey.com> - 2016-09-14 23:40 +0200
      Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-14 23:50 +0200
        Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Kyle Huey <me@kylehuey.com> - 2016-09-15 00:00 +0200
  Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. kbuild test robot <lkp@intel.com> - 2016-09-15 00:30 +0200
  Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. kbuild test robot <lkp@intel.com> - 2016-09-15 02:10 +0200
  Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. kbuild test robot <lkp@intel.com> - 2016-09-15 02:10 +0200
  Re: [PATCH v2 1/3] syscalls,x86 Expose arch_prctl on x86-32. Andy Lutomirski <luto@amacapital.net> - 2016-09-15 03:20 +0200

csiph-web