linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls
@ 2018-05-14 17:14 Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Kees Cook, Matt Turner,
	Michael Ellerman, Paul Mackerras, Ralf Baechle,
	Richard Henderson, Rich Felker, Thomas Gleixner, Tony Luck,
	Will Deacon, x86, Yoshinori Sato

[Reviewer note: this is a cross-arch series.  To reduce spam, I have
tried not to Cc people on patches they aren't likely to care about.
The complete series can be found in the LKML or linux-arch archives.]

The core framework for the prctl() syscall is unloved and looking
rather crusty these days.  It also relies on defining ancillary
boilerplate macros for each prctl() in order to control conditional
compilation of the different prctl calls.  We have better ways to
do this now.

This series attempts to modernise the code by defining a couple of new
Kconfig variables HAVE_PRCTL_ARCH and HAVE_ARCH_PR_SET_GET_UNALIGN to
allow architectures to provide hooks for arch-dependent prctls.


For now this series has had minimal testing: some basic testing of
arch-specific prctls using PR_SVE_SET_VL on arm64; build-tested on
x86; otherwise untested.

This is not polished yet... but I'm interested to know what people
think about the approach.

Cheers
---Dave


Dave Martin (11):
  prctl: Support movement of arch prctls out of common code
  arm64: Move arch-specific prctls out of core code
  MIPS: Remove unused task argument from prctl functions
  MIPS: Move arch-specific prctls out of core code
  x86: Move arch-specific prctls out of core code
  powerpc: Remove unused task argument from prctl functions
  powerpc: Move arch-specific prctls out of core code
  ia64: Remove unused task argument from prctl functions
  ia64: Move arch-specific prctls out of core code
  prctl: Remove redundant task argument from PR_{SET,GET}_UNALIGN
    backends
  prctl: Refactor PR_{SET,GET}_UNALIGN to reduce boilerplate

 arch/Kconfig                         |   6 ++
 arch/alpha/Kconfig                   |   1 +
 arch/alpha/include/asm/thread_info.h |  23 --------
 arch/alpha/kernel/Makefile           |   2 +-
 arch/alpha/kernel/sys.c              |  36 ++++++++++++
 arch/arm64/Kconfig                   |   1 +
 arch/arm64/include/asm/processor.h   |   4 --
 arch/arm64/kernel/sys.c              |  15 +++++
 arch/ia64/Kconfig                    |   2 +
 arch/ia64/include/asm/processor.h    |  24 --------
 arch/ia64/kernel/sys_ia64.c          |  37 ++++++++++++
 arch/mips/Kconfig                    |   1 +
 arch/mips/include/asm/processor.h    |   3 -
 arch/mips/kernel/process.c           |  23 ++++----
 arch/mips/kernel/syscall.c           |  15 +++++
 arch/parisc/Kconfig                  |   1 +
 arch/parisc/include/asm/processor.h  |  14 -----
 arch/parisc/kernel/sys_parisc.c      |  15 +++++
 arch/powerpc/Kconfig                 |   2 +
 arch/powerpc/include/asm/processor.h |  20 ++-----
 arch/powerpc/kernel/process.c        |  38 ++++++------
 arch/powerpc/kernel/syscalls.c       |  17 ++++++
 arch/sh/Kconfig                      |   1 +
 arch/sh/include/asm/processor.h      |   7 ---
 arch/sh/mm/alignment.c               |  12 ++--
 arch/x86/Kconfig                     |   1 +
 arch/x86/include/asm/processor.h     |   6 --
 arch/x86/kernel/Makefile             |   1 +
 arch/x86/kernel/sys.c                |  26 +++++++++
 include/linux/prctl.h                |  27 +++++++++
 include/uapi/linux/prctl.h           |   6 +-
 kernel/sys.c                         | 110 ++++-------------------------------
 tools/include/uapi/linux/prctl.h     |   6 +-
 33 files changed, 263 insertions(+), 240 deletions(-)
 create mode 100644 arch/alpha/kernel/sys.c
 create mode 100644 arch/x86/kernel/sys.c
 create mode 100644 include/linux/prctl.h

-- 
2.1.4

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-21 18:28   ` Will Deacon
  2018-05-14 17:14 ` [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code Dave Martin
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Kees Cook, Matt Turner,
	Michael Ellerman, Paul Mackerras, Ralf Baechle,
	Richard Henderson, Rich Felker, Thomas Gleixner, Tony Luck,
	Will Deacon, x86, Yoshinori Sato

The core framework for the prctl() syscall is unloved and looking
rather crusty these days.  It also relies on defining ancillary
boilerplate macros for each prctl() in order to control conditional
compilation of the different prctl calls.  We have better ways to
do this now, using Kconfig.

This patch defines a new arch hook arch_syscall().  Architectures
that implemement arch-specific syscalls can now select
HAVE_ARCH_SYSCALL in their Kconfig and define this function
appropriately.

The core prctl() implementation now matches option against the list
of common or legacy prctls, deferring to prctl_arch() if an
unrecognised option is encountered.

(arch_prctl() would have been a nicer name, but it conflicts with the
pre-existing syscall of the same name on x86, particularly in the um
code.)

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: James Hogan <jhogan@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Rich Felker <dalias@libc.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: x86@kernel.org
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/Kconfig                     |  3 +++
 include/linux/prctl.h            | 19 +++++++++++++++++++
 include/uapi/linux/prctl.h       |  6 +++---
 kernel/sys.c                     |  2 +-
 tools/include/uapi/linux/prctl.h |  6 +++---
 5 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 include/linux/prctl.h

diff --git a/arch/Kconfig b/arch/Kconfig
index 8e0d665..b34b3e8 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -969,4 +969,7 @@ config REFCOUNT_FULL
 	  against various use-after-free conditions that can be used in
 	  security flaw exploits.
 
+config HAVE_PRCTL_ARCH
+	bool
+
 source "kernel/gcov/Kconfig"
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
new file mode 100644
index 0000000..5ce3713
--- /dev/null
+++ b/include/linux/prctl.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_PRCTL_H
+#define _LINUX_PRCTL_H
+
+#include <linux/errno.h>
+#include <uapi/linux/prctl.h>
+
+#ifdef CONFIG_HAVE_PRCTL_ARCH
+extern int prctl_arch(int option, unsigned long arg2,
+	unsigned long arg3, unsigned long arg4, unsigned long arg5);
+#else
+static inline int prctl_arch(int option, unsigned long arg2,
+	unsigned long arg3, unsigned long arg4, unsigned long arg5)
+{
+	return -EINVAL;
+}
+#endif
+
+#endif /* ! _LINUX_PRCTL_H */
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index af5f8c2..c911ff0 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _LINUX_PRCTL_H
-#define _LINUX_PRCTL_H
+#ifndef _UAPI_LINUX_PRCTL_H
+#define _UAPI_LINUX_PRCTL_H
 
 #include <linux/types.h>
 
@@ -207,4 +207,4 @@ struct prctl_mm_map {
 # define PR_SVE_VL_LEN_MASK		0xffff
 # define PR_SVE_VL_INHERIT		(1 << 17) /* inherit across exec */
 
-#endif /* _LINUX_PRCTL_H */
+#endif /* _UAPI_LINUX_PRCTL_H */
diff --git a/kernel/sys.c b/kernel/sys.c
index ad69218..5077f1e 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2451,7 +2451,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		error = SVE_GET_VL();
 		break;
 	default:
-		error = -EINVAL;
+		error = prctl_arch(option, arg2, arg3, arg4, arg5);
 		break;
 	}
 	return error;
diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index af5f8c2..c911ff0 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _LINUX_PRCTL_H
-#define _LINUX_PRCTL_H
+#ifndef _UAPI_LINUX_PRCTL_H
+#define _UAPI_LINUX_PRCTL_H
 
 #include <linux/types.h>
 
@@ -207,4 +207,4 @@ struct prctl_mm_map {
 # define PR_SVE_VL_LEN_MASK		0xffff
 # define PR_SVE_VL_INHERIT		(1 << 17) /* inherit across exec */
 
-#endif /* _LINUX_PRCTL_H */
+#endif /* _UAPI_LINUX_PRCTL_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-21 18:30   ` Will Deacon
  2018-05-14 17:14 ` [RFC PATCH 03/11] MIPS: Remove unused task argument from prctl functions Dave Martin
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, Catalin Marinas, Will Deacon

This patch moves the arm64-specific prctl call implementations out
of core code and removes redundant boilerplate associated with
them.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/Kconfig                 |  1 +
 arch/arm64/include/asm/processor.h |  4 ----
 arch/arm64/kernel/sys.c            | 15 +++++++++++++++
 kernel/sys.c                       | 12 ------------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index eb2cf49..6b706af 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -123,6 +123,7 @@ config ARM64
 	select HAVE_PERF_EVENTS
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
+	select HAVE_PRCTL_ARCH
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RCU_TABLE_FREE
 	select HAVE_SYSCALL_TRACEPOINTS
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 7675989..b1d262f 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -244,9 +244,5 @@ void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused);
 void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused);
 void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused);
 
-/* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */
-#define SVE_SET_VL(arg)	sve_set_current_vl(arg)
-#define SVE_GET_VL()	sve_get_current_vl()
-
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_PROCESSOR_H */
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index 72981ba..597ff35 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -22,10 +22,12 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/export.h>
+#include <linux/prctl.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <asm/cpufeature.h>
+#include <asm/fpsimd.h>
 
 asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
 			 unsigned long prot, unsigned long flags,
@@ -45,6 +47,19 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
 	return sys_personality(personality);
 }
 
+int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
+	       unsigned long arg4, unsigned long arg5)
+{
+	switch (option) {
+	case PR_SVE_SET_VL:
+		return sve_set_current_vl(arg2);
+	case PR_SVE_GET_VL:
+		return sve_get_current_vl();
+	default:
+		return -EINVAL;
+	}
+}
+
 /*
  * Wrappers to pass the pt_regs argument.
  */
diff --git a/kernel/sys.c b/kernel/sys.c
index 5077f1e..f917d78 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -113,12 +113,6 @@
 #ifndef SET_FP_MODE
 # define SET_FP_MODE(a,b)	(-EINVAL)
 #endif
-#ifndef SVE_SET_VL
-# define SVE_SET_VL(a)		(-EINVAL)
-#endif
-#ifndef SVE_GET_VL
-# define SVE_GET_VL()		(-EINVAL)
-#endif
 
 /*
  * this is where the system-wide overflow UID and GID are defined, for
@@ -2444,12 +2438,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_GET_FP_MODE:
 		error = GET_FP_MODE(me);
 		break;
-	case PR_SVE_SET_VL:
-		error = SVE_SET_VL(arg2);
-		break;
-	case PR_SVE_GET_VL:
-		error = SVE_GET_VL();
-		break;
 	default:
 		error = prctl_arch(option, arg2, arg3, arg4, arg5);
 		break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 03/11] MIPS: Remove unused task argument from prctl functions
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 04/11] MIPS: Move arch-specific prctls out of core code Dave Martin
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, Ralf Baechle, James Hogan

Some MIPS-specific prctl backends take a task argument that is
redundant, since the only thing ever passed is "current".

This patch gets rid of the redundant arguments.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
---
 arch/mips/include/asm/processor.h |  4 ++--
 arch/mips/kernel/process.c        | 23 +++++++++++------------
 arch/mips/kernel/syscall.c        |  1 +
 kernel/sys.c                      |  8 ++++----
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index af34afb..8f06608 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -420,7 +420,7 @@ extern int mips_get_process_fp_mode(struct task_struct *task);
 extern int mips_set_process_fp_mode(struct task_struct *task,
 				    unsigned int value);
 
-#define GET_FP_MODE(task)		mips_get_process_fp_mode(task)
-#define SET_FP_MODE(task,value)		mips_set_process_fp_mode(task, value)
+#define GET_FP_MODE()			mips_get_process_fp_mode()
+#define SET_FP_MODE(value)		mips_set_process_fp_mode(value)
 
 #endif /* _ASM_PROCESSOR_H */
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index b9e9bf6..7db1989 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -679,13 +679,13 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
 	put_cpu();
 }
 
-int mips_get_process_fp_mode(struct task_struct *task)
+int mips_get_process_fp_mode(void)
 {
 	int value = 0;
 
-	if (!test_tsk_thread_flag(task, TIF_32BIT_FPREGS))
+	if (!test_thread_flag(TIF_32BIT_FPREGS))
 		value |= PR_FP_MODE_FR;
-	if (test_tsk_thread_flag(task, TIF_HYBRID_FPREGS))
+	if (test_thread_flag(TIF_HYBRID_FPREGS))
 		value |= PR_FP_MODE_FRE;
 
 	return value;
@@ -699,14 +699,14 @@ static void prepare_for_fp_mode_switch(void *info)
 		lose_fpu(1);
 }
 
-int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
+int mips_set_process_fp_mode(unsigned int value)
 {
 	const unsigned int known_bits = PR_FP_MODE_FR | PR_FP_MODE_FRE;
 	struct task_struct *t;
 	int max_users;
 
 	/* If nothing to change, return right away, successfully.  */
-	if (value == mips_get_process_fp_mode(task))
+	if (value == mips_get_process_fp_mode())
 		return 0;
 
 	/* Only accept a mode change if 64-bit FP enabled for o32.  */
@@ -736,11 +736,10 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 	preempt_disable();
 
 	/* Save FP & vector context, then disable FPU & MSA */
-	if (task->signal == current->signal)
-		lose_fpu(1);
+	lose_fpu(1);
 
 	/* Prevent any threads from obtaining live FP context */
-	atomic_set(&task->mm->context.fp_mode_switching, 1);
+	atomic_set(&current->mm->context.fp_mode_switching, 1);
 	smp_mb__after_atomic();
 
 	/*
@@ -750,7 +749,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 	 */
 	if (num_online_cpus() > 1) {
 		/* No need to send an IPI for the local CPU */
-		max_users = (task->mm == current->mm) ? 1 : 0;
+		max_users = (current->mm == current->mm) ? 1 : 0;
 
 		if (atomic_read(&current->mm->mm_users) > max_users)
 			smp_call_function(prepare_for_fp_mode_switch,
@@ -761,7 +760,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 	 * There are now no threads of the process with live FP context, so it
 	 * is safe to proceed with the FP mode switch.
 	 */
-	for_each_thread(task, t) {
+	for_each_thread(current, t) {
 		/* Update desired FP register width */
 		if (value & PR_FP_MODE_FR) {
 			clear_tsk_thread_flag(t, TIF_32BIT_FPREGS);
@@ -778,10 +777,10 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 	}
 
 	/* Allow threads to use FP again */
-	atomic_set(&task->mm->context.fp_mode_switching, 0);
+	atomic_set(&current->mm->context.fp_mode_switching, 0);
 	preempt_enable();
 
-	wake_up_var(&task->mm->context.fp_mode_switching);
+	wake_up_var(&current->mm->context.fp_mode_switching);
 
 	return 0;
 }
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 69c17b5..15f33f0 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -12,6 +12,7 @@
 #include <linux/linkage.h>
 #include <linux/fs.h>
 #include <linux/smp.h>
+#include <linux/prctl.h>
 #include <linux/ptrace.h>
 #include <linux/string.h>
 #include <linux/syscalls.h>
diff --git a/kernel/sys.c b/kernel/sys.c
index f917d78..520d2e8 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -108,10 +108,10 @@
 # define MPX_DISABLE_MANAGEMENT()	(-EINVAL)
 #endif
 #ifndef GET_FP_MODE
-# define GET_FP_MODE(a)		(-EINVAL)
+# define GET_FP_MODE()		(-EINVAL)
 #endif
 #ifndef SET_FP_MODE
-# define SET_FP_MODE(a,b)	(-EINVAL)
+# define SET_FP_MODE(a)		(-EINVAL)
 #endif
 
 /*
@@ -2433,10 +2433,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		error = MPX_DISABLE_MANAGEMENT();
 		break;
 	case PR_SET_FP_MODE:
-		error = SET_FP_MODE(me, arg2);
+		error = SET_FP_MODE(arg2);
 		break;
 	case PR_GET_FP_MODE:
-		error = GET_FP_MODE(me);
+		error = GET_FP_MODE();
 		break;
 	default:
 		error = prctl_arch(option, arg2, arg3, arg4, arg5);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 04/11] MIPS: Move arch-specific prctls out of core code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (2 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 03/11] MIPS: Remove unused task argument from prctl functions Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 05/11] x86: " Dave Martin
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, Ralf Baechle, James Hogan

This patch moves the MIPS-specific prctl call implementations out
of core code and removes redundant boilerplate associated with
them.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
---
 arch/mips/Kconfig                 |  1 +
 arch/mips/include/asm/processor.h |  3 ---
 arch/mips/kernel/syscall.c        | 14 ++++++++++++++
 kernel/sys.c                      | 12 ------------
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 225c95d..99eb2ef 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -61,6 +61,7 @@ config MIPS
 	select HAVE_NMI
 	select HAVE_OPROFILE
 	select HAVE_PERF_EVENTS
+	select HAVE_PRCTL_ARCH
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_SYSCALL_TRACEPOINTS
 	select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 8f06608..4a8079a 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -420,7 +420,4 @@ extern int mips_get_process_fp_mode(struct task_struct *task);
 extern int mips_set_process_fp_mode(struct task_struct *task,
 				    unsigned int value);
 
-#define GET_FP_MODE()			mips_get_process_fp_mode()
-#define SET_FP_MODE(value)		mips_set_process_fp_mode(value)
-
 #endif /* _ASM_PROCESSOR_H */
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 15f33f0..aa8157c 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -35,6 +35,7 @@
 #include <asm/cachectl.h>
 #include <asm/cacheflush.h>
 #include <asm/asm-offsets.h>
+#include <asm/processor.h>
 #include <asm/signal.h>
 #include <asm/sim.h>
 #include <asm/shmparam.h>
@@ -237,6 +238,19 @@ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op)
 	return -ENOSYS;
 }
 
+int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
+	       unsigned long arg4, unsigned long arg5)
+{
+	switch (option) {
+	case PR_SET_FP_MODE:
+		return mips_set_process_fp_mode(arg2);
+	case PR_GET_FP_MODE:
+		return mips_get_process_fp_mode();
+	default:
+		return -EINVAL;
+	}
+}
+
 /*
  * If we ever come here the user sp is bad.  Zap the process right away.
  * Due to the bad stack signaling wouldn't work.
diff --git a/kernel/sys.c b/kernel/sys.c
index 520d2e8..63228e7 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -107,12 +107,6 @@
 #ifndef MPX_DISABLE_MANAGEMENT
 # define MPX_DISABLE_MANAGEMENT()	(-EINVAL)
 #endif
-#ifndef GET_FP_MODE
-# define GET_FP_MODE()		(-EINVAL)
-#endif
-#ifndef SET_FP_MODE
-# define SET_FP_MODE(a)		(-EINVAL)
-#endif
 
 /*
  * this is where the system-wide overflow UID and GID are defined, for
@@ -2432,12 +2426,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 			return -EINVAL;
 		error = MPX_DISABLE_MANAGEMENT();
 		break;
-	case PR_SET_FP_MODE:
-		error = SET_FP_MODE(arg2);
-		break;
-	case PR_GET_FP_MODE:
-		error = GET_FP_MODE();
-		break;
 	default:
 		error = prctl_arch(option, arg2, arg3, arg4, arg5);
 		break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 05/11] x86: Move arch-specific prctls out of core code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (3 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 04/11] MIPS: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions Dave Martin
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86

This patch moves the x86-specific prctl call implementations out
of core code and removes redundant boilerplate associated with
them.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/Kconfig                 |  1 +
 arch/x86/include/asm/processor.h |  6 ------
 arch/x86/kernel/Makefile         |  1 +
 arch/x86/kernel/sys.c            | 26 ++++++++++++++++++++++++++
 kernel/sys.c                     | 28 ----------------------------
 5 files changed, 28 insertions(+), 34 deletions(-)
 create mode 100644 arch/x86/kernel/sys.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c07f492..7bae36a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -176,6 +176,7 @@ config X86
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
+	select HAVE_PRCTL_ARCH
 	select HAVE_RCU_TABLE_FREE
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RELIABLE_STACKTRACE		if X86_64 && UNWINDER_FRAME_POINTER && STACK_VALIDATION
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 21a1149..0ecdda4 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -924,18 +924,12 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
 #define KSTK_EIP(task)		(task_pt_regs(task)->ip)
 
 /* Get/set a process' ability to use the timestamp counter instruction */
-#define GET_TSC_CTL(adr)	get_tsc_mode((adr))
-#define SET_TSC_CTL(val)	set_tsc_mode((val))
-
 extern int get_tsc_mode(unsigned long adr);
 extern int set_tsc_mode(unsigned int val);
 
 DECLARE_PER_CPU(u64, msr_misc_features_shadow);
 
 /* Register/unregister a process' MPX related resource */
-#define MPX_ENABLE_MANAGEMENT()	mpx_enable_management()
-#define MPX_DISABLE_MANAGEMENT()	mpx_disable_management()
-
 #ifdef CONFIG_X86_INTEL_MPX
 extern int mpx_enable_management(void);
 extern int mpx_disable_management(void);
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 02d6f5c..636e40d 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_MODIFY_LDT_SYSCALL)	+= ldt.o
 obj-y			+= setup.o x86_init.o i8259.o irqinit.o jump_label.o
 obj-$(CONFIG_IRQ_WORK)  += irq_work.o
 obj-y			+= probe_roms.o
+obj-y			+= sys.o
 obj-$(CONFIG_X86_64)	+= sys_x86_64.o
 obj-$(CONFIG_X86_ESPFIX64)	+= espfix_64.o
 obj-$(CONFIG_SYSFS)	+= ksysfs.o
diff --git a/arch/x86/kernel/sys.c b/arch/x86/kernel/sys.c
new file mode 100644
index 0000000..3be4d16
--- /dev/null
+++ b/arch/x86/kernel/sys.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/errno.h>
+#include <linux/prctl.h>
+#include <asm/processor.h>
+
+int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
+	       unsigned long arg4, unsigned long arg5)
+{
+	switch (option) {
+	case PR_GET_TSC:
+		return get_tsc_mode(arg2);
+	case PR_SET_TSC:
+		return set_tsc_mode(arg2);
+	case PR_MPX_ENABLE_MANAGEMENT:
+		if (arg2 || arg3 || arg4 || arg5)
+			return -EINVAL;
+		return mpx_enable_management();
+	case PR_MPX_DISABLE_MANAGEMENT:
+		if (arg2 || arg3 || arg4 || arg5)
+			return -EINVAL;
+		return mpx_disable_management();
+	default:
+		return -EINVAL;
+	}
+}
diff --git a/kernel/sys.c b/kernel/sys.c
index 63228e7..994b5711 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -95,18 +95,6 @@
 #ifndef SET_ENDIAN
 # define SET_ENDIAN(a, b)	(-EINVAL)
 #endif
-#ifndef GET_TSC_CTL
-# define GET_TSC_CTL(a)		(-EINVAL)
-#endif
-#ifndef SET_TSC_CTL
-# define SET_TSC_CTL(a)		(-EINVAL)
-#endif
-#ifndef MPX_ENABLE_MANAGEMENT
-# define MPX_ENABLE_MANAGEMENT()	(-EINVAL)
-#endif
-#ifndef MPX_DISABLE_MANAGEMENT
-# define MPX_DISABLE_MANAGEMENT()	(-EINVAL)
-#endif
 
 /*
  * this is where the system-wide overflow UID and GID are defined, for
@@ -2314,12 +2302,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_SET_SECCOMP:
 		error = prctl_set_seccomp(arg2, (char __user *)arg3);
 		break;
-	case PR_GET_TSC:
-		error = GET_TSC_CTL(arg2);
-		break;
-	case PR_SET_TSC:
-		error = SET_TSC_CTL(arg2);
-		break;
 	case PR_TASK_PERF_EVENTS_DISABLE:
 		error = perf_event_task_disable();
 		break;
@@ -2416,16 +2398,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 			clear_bit(MMF_DISABLE_THP, &me->mm->flags);
 		up_write(&me->mm->mmap_sem);
 		break;
-	case PR_MPX_ENABLE_MANAGEMENT:
-		if (arg2 || arg3 || arg4 || arg5)
-			return -EINVAL;
-		error = MPX_ENABLE_MANAGEMENT();
-		break;
-	case PR_MPX_DISABLE_MANAGEMENT:
-		if (arg2 || arg3 || arg4 || arg5)
-			return -EINVAL;
-		error = MPX_DISABLE_MANAGEMENT();
-		break;
 	default:
 		error = prctl_arch(option, arg2, arg3, arg4, arg5);
 		break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (4 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 05/11] x86: " Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-15  3:05   ` Michael Ellerman
  2018-05-14 17:14 ` [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code Dave Martin
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman

Some powerpc-specific prctl backends take a task argument that is
redundant, since the only thing ever passed is "current".

This patch gets rid of the redundant arguments.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/processor.h | 16 ++++++++--------
 arch/powerpc/kernel/process.c        | 30 +++++++++++++++---------------
 kernel/sys.c                         | 12 ++++++------
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index c4b36a4..313dec1 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -407,17 +407,17 @@ unsigned long get_wchan(struct task_struct *p);
 #define KSTK_ESP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
 
 /* Get/set floating-point exception mode */
-#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
-#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
+#define GET_FPEXC_CTL(adr) get_fpexc_mode((adr))
+#define SET_FPEXC_CTL(val) set_fpexc_mode((val))
 
-extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
-extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
+extern int get_fpexc_mode(unsigned long adr);
+extern int set_fpexc_mode(unsigned int val);
 
-#define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr))
-#define SET_ENDIAN(tsk, val) set_endian((tsk), (val))
+#define GET_ENDIAN(adr) get_endian((adr))
+#define SET_ENDIAN(val) set_endian((val))
 
-extern int get_endian(struct task_struct *tsk, unsigned long adr);
-extern int set_endian(struct task_struct *tsk, unsigned int val);
+extern int get_endian(unsigned long adr);
+extern int set_endian(unsigned int val);
 
 #define GET_UNALIGN_CTL(tsk, adr)	get_unalign_ctl((tsk), (adr))
 #define SET_UNALIGN_CTL(tsk, val)	set_unalign_ctl((tsk), (val))
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 1237f13..0fcb2f5 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1896,9 +1896,9 @@ EXPORT_SYMBOL(start_thread);
 #define PR_FP_ALL_EXCEPT (PR_FP_EXC_DIV | PR_FP_EXC_OVF | PR_FP_EXC_UND \
 		| PR_FP_EXC_RES | PR_FP_EXC_INV)
 
-int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
+int set_fpexc_mode(unsigned int val)
 {
-	struct pt_regs *regs = tsk->thread.regs;
+	struct pt_regs *regs = current->thread.regs;
 
 	/* This is a bit hairy.  If we are an SPE enabled  processor
 	 * (have embedded fp) we store the IEEE exception enable flags in
@@ -1919,8 +1919,8 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
 			 * anyway to restore the prctl settings from
 			 * the saved environment.
 			 */
-			tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
-			tsk->thread.fpexc_mode = val &
+			current->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
+			current->thread.fpexc_mode = val &
 				(PR_FP_EXC_SW_ENABLE | PR_FP_ALL_EXCEPT);
 			return 0;
 		} else {
@@ -1938,18 +1938,18 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
 	 * them does not change anything */
 	if (val > PR_FP_EXC_PRECISE)
 		return -EINVAL;
-	tsk->thread.fpexc_mode = __pack_fe01(val);
+	current->thread.fpexc_mode = __pack_fe01(val);
 	if (regs != NULL && (regs->msr & MSR_FP) != 0)
 		regs->msr = (regs->msr & ~(MSR_FE0|MSR_FE1))
-			| tsk->thread.fpexc_mode;
+			| current->thread.fpexc_mode;
 	return 0;
 }
 
-int get_fpexc_mode(struct task_struct *tsk, unsigned long adr)
+int get_fpexc_mode(unsigned long adr)
 {
 	unsigned int val;
 
-	if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE)
+	if (current->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE)
 #ifdef CONFIG_SPE
 		if (cpu_has_feature(CPU_FTR_SPE)) {
 			/*
@@ -1964,21 +1964,21 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr)
 			 * anyway to restore the prctl settings from
 			 * the saved environment.
 			 */
-			tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
-			val = tsk->thread.fpexc_mode;
+			current->thread.spefscr_last = mfspr(SPRN_SPEFSCR);
+			val = current->thread.fpexc_mode;
 		} else
 			return -EINVAL;
 #else
 		return -EINVAL;
 #endif
 	else
-		val = __unpack_fe01(tsk->thread.fpexc_mode);
+		val = __unpack_fe01(current->thread.fpexc_mode);
 	return put_user(val, (unsigned int __user *) adr);
 }
 
-int set_endian(struct task_struct *tsk, unsigned int val)
+int set_endian(unsigned int val)
 {
-	struct pt_regs *regs = tsk->thread.regs;
+	struct pt_regs *regs = current->thread.regs;
 
 	if ((val == PR_ENDIAN_LITTLE && !cpu_has_feature(CPU_FTR_REAL_LE)) ||
 	    (val == PR_ENDIAN_PPC_LITTLE && !cpu_has_feature(CPU_FTR_PPC_LE)))
@@ -1997,9 +1997,9 @@ int set_endian(struct task_struct *tsk, unsigned int val)
 	return 0;
 }
 
-int get_endian(struct task_struct *tsk, unsigned long adr)
+int get_endian(unsigned long adr)
 {
-	struct pt_regs *regs = tsk->thread.regs;
+	struct pt_regs *regs = current->thread.regs;
 	unsigned int val;
 
 	if (!cpu_has_feature(CPU_FTR_PPC_LE) &&
diff --git a/kernel/sys.c b/kernel/sys.c
index 994b5711..44e1c47 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -90,10 +90,10 @@
 # define GET_FPEXC_CTL(a, b)	(-EINVAL)
 #endif
 #ifndef GET_ENDIAN
-# define GET_ENDIAN(a, b)	(-EINVAL)
+# define GET_ENDIAN(b)		(-EINVAL)
 #endif
 #ifndef SET_ENDIAN
-# define SET_ENDIAN(a, b)	(-EINVAL)
+# define SET_ENDIAN(b)		(-EINVAL)
 #endif
 
 /*
@@ -2265,10 +2265,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		error = GET_FPEMU_CTL(me, arg2);
 		break;
 	case PR_SET_FPEXC:
-		error = SET_FPEXC_CTL(me, arg2);
+		error = SET_FPEXC_CTL(arg2);
 		break;
 	case PR_GET_FPEXC:
-		error = GET_FPEXC_CTL(me, arg2);
+		error = GET_FPEXC_CTL(arg2);
 		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
@@ -2291,10 +2291,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 			return -EFAULT;
 		break;
 	case PR_GET_ENDIAN:
-		error = GET_ENDIAN(me, arg2);
+		error = GET_ENDIAN(arg2);
 		break;
 	case PR_SET_ENDIAN:
-		error = SET_ENDIAN(me, arg2);
+		error = SET_ENDIAN(arg2);
 		break;
 	case PR_GET_SECCOMP:
 		error = prctl_get_seccomp();
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (5 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-15  3:06   ` Michael Ellerman
  2018-05-14 17:14 ` [RFC PATCH 08/11] ia64: Remove unused task argument from prctl functions Dave Martin
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman

This patch moves the powerpc-specific prctl call implementations
out of core code and removes redundant boilerplate associated with
them.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/Kconfig                 |  1 +
 arch/powerpc/include/asm/processor.h |  6 ------
 arch/powerpc/kernel/syscalls.c       | 17 +++++++++++++++++
 kernel/sys.c                         | 24 ------------------------
 4 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c32a181..b94323e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -218,6 +218,7 @@ config PPC
 	select HAVE_HARDLOCKUP_DETECTOR_PERF	if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
+	select HAVE_PRCTL_ARCH
 	select HAVE_RCU_TABLE_FREE		if SMP
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_SYSCALL_TRACEPOINTS
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 313dec1..e1cd7ec 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -407,15 +407,9 @@ unsigned long get_wchan(struct task_struct *p);
 #define KSTK_ESP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
 
 /* Get/set floating-point exception mode */
-#define GET_FPEXC_CTL(adr) get_fpexc_mode((adr))
-#define SET_FPEXC_CTL(val) set_fpexc_mode((val))
-
 extern int get_fpexc_mode(unsigned long adr);
 extern int set_fpexc_mode(unsigned int val);
 
-#define GET_ENDIAN(adr) get_endian((adr))
-#define SET_ENDIAN(val) set_endian((val))
-
 extern int get_endian(unsigned long adr);
 extern int set_endian(unsigned int val);
 
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index 4662165..0d6a914 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -139,3 +139,20 @@ long sys_switch_endian(void)
 
 	return 0;
 }
+
+int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
+	       unsigned long arg4, unsigned long arg5)
+{
+	switch (option) {
+	case PR_SET_FPEXC:
+		return set_fpexc_mode(arg2);
+	case PR_GET_FPEXC:
+		return get_fpexc_mode(arg2);
+	case PR_GET_ENDIAN:
+		return get_endian(arg2);
+	case PR_SET_ENDIAN:
+		return set_endian(arg2);
+	default:
+		return -EINVAL;
+	}
+}
diff --git a/kernel/sys.c b/kernel/sys.c
index 44e1c47..b154561 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -83,18 +83,6 @@
 #ifndef GET_FPEMU_CTL
 # define GET_FPEMU_CTL(a, b)	(-EINVAL)
 #endif
-#ifndef SET_FPEXC_CTL
-# define SET_FPEXC_CTL(a, b)	(-EINVAL)
-#endif
-#ifndef GET_FPEXC_CTL
-# define GET_FPEXC_CTL(a, b)	(-EINVAL)
-#endif
-#ifndef GET_ENDIAN
-# define GET_ENDIAN(b)		(-EINVAL)
-#endif
-#ifndef SET_ENDIAN
-# define SET_ENDIAN(b)		(-EINVAL)
-#endif
 
 /*
  * this is where the system-wide overflow UID and GID are defined, for
@@ -2264,12 +2252,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_GET_FPEMU:
 		error = GET_FPEMU_CTL(me, arg2);
 		break;
-	case PR_SET_FPEXC:
-		error = SET_FPEXC_CTL(arg2);
-		break;
-	case PR_GET_FPEXC:
-		error = GET_FPEXC_CTL(arg2);
-		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
 		break;
@@ -2290,12 +2272,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		if (copy_to_user((char __user *)arg2, comm, sizeof(comm)))
 			return -EFAULT;
 		break;
-	case PR_GET_ENDIAN:
-		error = GET_ENDIAN(arg2);
-		break;
-	case PR_SET_ENDIAN:
-		error = SET_ENDIAN(arg2);
-		break;
 	case PR_GET_SECCOMP:
 		error = prctl_get_seccomp();
 		break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 08/11] ia64: Remove unused task argument from prctl functions
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (6 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 09/11] ia64: Move arch-specific prctls out of core code Dave Martin
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, Tony Luck, Fenghua Yu

Some ia64-specific prctl backends take a task argument that is
redundant, since the only thing ever passed is "current".

This patch gets rid of the redundant arguments.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/include/asm/processor.h | 8 ++++----
 kernel/sys.c                      | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 10061ccf..0489b80 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -259,15 +259,15 @@ typedef struct {
 		 (int __user *) (addr));							\
 })
 
-#define SET_FPEMU_CTL(task,value)								\
+#define SET_FPEMU_CTL(value)									\
 ({												\
-	(task)->thread.flags = (((task)->thread.flags & ~IA64_THREAD_FPEMU_MASK)		\
+	current->thread.flags = ((current->thread.flags & ~IA64_THREAD_FPEMU_MASK)		\
 			  | (((value) << IA64_THREAD_FPEMU_SHIFT) & IA64_THREAD_FPEMU_MASK));	\
 	0;											\
 })
-#define GET_FPEMU_CTL(task,addr)								\
+#define GET_FPEMU_CTL(addr)									\
 ({												\
-	put_user(((task)->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT,	\
+	put_user((current->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT,	\
 		 (int __user *) (addr));							\
 })
 
diff --git a/kernel/sys.c b/kernel/sys.c
index b154561..5549505 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -78,10 +78,10 @@
 # define GET_UNALIGN_CTL(a, b)	(-EINVAL)
 #endif
 #ifndef SET_FPEMU_CTL
-# define SET_FPEMU_CTL(a, b)	(-EINVAL)
+# define SET_FPEMU_CTL(a)	(-EINVAL)
 #endif
 #ifndef GET_FPEMU_CTL
-# define GET_FPEMU_CTL(a, b)	(-EINVAL)
+# define GET_FPEMU_CTL(a)	(-EINVAL)
 #endif
 
 /*
@@ -2247,10 +2247,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		error = GET_UNALIGN_CTL(me, arg2);
 		break;
 	case PR_SET_FPEMU:
-		error = SET_FPEMU_CTL(me, arg2);
+		error = SET_FPEMU_CTL(arg2);
 		break;
 	case PR_GET_FPEMU:
-		error = GET_FPEMU_CTL(me, arg2);
+		error = GET_FPEMU_CTL(arg2);
 		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 09/11] ia64: Move arch-specific prctls out of core code
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (7 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 08/11] ia64: Remove unused task argument from prctl functions Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 10/11] prctl: Remove redundant task argument from PR_{SET,GET}_UNALIGN backends Dave Martin
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, Tony Luck, Fenghua Yu

This patch moves the ia64-specific prctl call implementations out
of core code and removes redundant boilerplate associated with
them.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/Kconfig                 |  1 +
 arch/ia64/include/asm/processor.h | 12 ------------
 arch/ia64/kernel/sys_ia64.c       | 22 ++++++++++++++++++++++
 kernel/sys.c                      | 12 ------------
 4 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index bbe12a0..a673dd7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -54,6 +54,7 @@ config IA64
 	select MODULES_USE_ELF_RELA
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select HAVE_ARCH_AUDITSYSCALL
+	select HAVE_PRCTL_ARCH
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 0489b80..e40242e 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -259,18 +259,6 @@ typedef struct {
 		 (int __user *) (addr));							\
 })
 
-#define SET_FPEMU_CTL(value)									\
-({												\
-	current->thread.flags = ((current->thread.flags & ~IA64_THREAD_FPEMU_MASK)		\
-			  | (((value) << IA64_THREAD_FPEMU_SHIFT) & IA64_THREAD_FPEMU_MASK));	\
-	0;											\
-})
-#define GET_FPEMU_CTL(addr)									\
-({												\
-	put_user((current->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT,	\
-		 (int __user *) (addr));							\
-})
-
 struct thread_struct {
 	__u32 flags;			/* various thread flags (see IA64_THREAD_*) */
 	/* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
index 9ebe1d6..d996585 100644
--- a/arch/ia64/kernel/sys_ia64.c
+++ b/arch/ia64/kernel/sys_ia64.c
@@ -15,11 +15,13 @@
 #include <linux/sched/task_stack.h>
 #include <linux/shm.h>
 #include <linux/file.h>		/* doh, must come after sched.h... */
+#include <liunx/prctl.h>
 #include <linux/smp.h>
 #include <linux/syscalls.h>
 #include <linux/highuid.h>
 #include <linux/hugetlb.h>
 
+#include <asm/processor.h>
 #include <asm/shmparam.h>
 #include <linux/uaccess.h>
 
@@ -184,3 +186,23 @@ sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, un
 }
 
 #endif /* CONFIG_PCI */
+
+int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
+	       unsigned long arg4, unsigned long arg5)
+{
+	int res;
+
+	switch (option) {
+	case PR_SET_FPEMU:
+		current->thread.flags &= ~IA64_THREAD_FPEMU_MASK;
+		current->thread.flags |= (arg2 << IA64_THREAD_FPEMU_SHIFT) &
+			IA64_THREAD_FPEMU_MASK;
+		return 0;
+	case PR_GET_FPEMU:
+		res = (current->thread.flags & IA64_THREAD_FPEMU_MASK) >>
+			IA64_THREAD_FPEMU_SHIFT;
+		return put_user(res, (int __user *)arg2);
+	default:
+		return -EINVAL;
+	}
+}
diff --git a/kernel/sys.c b/kernel/sys.c
index 5549505..8111c0d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -77,12 +77,6 @@
 #ifndef GET_UNALIGN_CTL
 # define GET_UNALIGN_CTL(a, b)	(-EINVAL)
 #endif
-#ifndef SET_FPEMU_CTL
-# define SET_FPEMU_CTL(a)	(-EINVAL)
-#endif
-#ifndef GET_FPEMU_CTL
-# define GET_FPEMU_CTL(a)	(-EINVAL)
-#endif
 
 /*
  * this is where the system-wide overflow UID and GID are defined, for
@@ -2246,12 +2240,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_GET_UNALIGN:
 		error = GET_UNALIGN_CTL(me, arg2);
 		break;
-	case PR_SET_FPEMU:
-		error = SET_FPEMU_CTL(arg2);
-		break;
-	case PR_GET_FPEMU:
-		error = GET_FPEMU_CTL(arg2);
-		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
 		break;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 10/11] prctl: Remove redundant task argument from PR_{SET,GET}_UNALIGN backends
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (8 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 09/11] ia64: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 17:14 ` [RFC PATCH 11/11] prctl: Refactor PR_{SET,GET}_UNALIGN to reduce boilerplate Dave Martin
  2018-05-14 18:28 ` [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Kees Cook
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Kees Cook, Andrew Morton, Ingo Molnar,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Tony Luck,
	Fenghua Yu, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker

Architecture backends for the PT_SET_UNALIGN and PR_GET_UNALIGN
prctl() calls take a task argument that is redundant, since the
only thing ever passed is "current".

This patch gets rid of the redundant arguments.

No functional change.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
---
 arch/alpha/include/asm/thread_info.h | 10 +++++-----
 arch/ia64/include/asm/processor.h    |  8 ++++----
 arch/parisc/include/asm/processor.h  |  8 ++++----
 arch/powerpc/include/asm/processor.h |  8 ++++----
 arch/powerpc/kernel/process.c        |  8 ++++----
 arch/sh/include/asm/processor.h      |  8 ++++----
 arch/sh/mm/alignment.c               | 10 +++++-----
 kernel/sys.c                         |  8 ++++----
 8 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index 807d7b9..403b3c8 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -85,19 +85,19 @@ register struct thread_info *__current_thread_info __asm__("$8");
 #define TS_UAC_NOFIX		0x0002	/* ! flags as they match          */
 #define TS_UAC_SIGBUS		0x0004	/* ! userspace part of 'osf_sysinfo' */
 
-#define SET_UNALIGN_CTL(task,value)	({				\
-	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
+#define SET_UNALIGN_CTL(value)	({					\
+	__u32 status = current_thread_info()->status & ~UAC_BITMASK;	\
 	if (value & PR_UNALIGN_NOPRINT)					\
 		status |= TS_UAC_NOPRINT;				\
 	if (value & PR_UNALIGN_SIGBUS)					\
 		status |= TS_UAC_SIGBUS;				\
 	if (value & 4)	/* alpha-specific */				\
 		status |= TS_UAC_NOFIX;					\
-	task_thread_info(task)->status = status;			\
+	current_thread_info()->status = status;				\
 	0; })
 
-#define GET_UNALIGN_CTL(task,value)	({				\
-	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
+#define GET_UNALIGN_CTL(value)	({					\
+	__u32 status = current_thread_info()->status & ~UAC_BITMASK;	\
 	__u32 res = 0;							\
 	if (status & TS_UAC_NOPRINT)					\
 		res |= PR_UNALIGN_NOPRINT;				\
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index e40242e..8d5184f 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -247,15 +247,15 @@ typedef struct {
 	unsigned long seg;
 } mm_segment_t;
 
-#define SET_UNALIGN_CTL(task,value)								\
+#define SET_UNALIGN_CTL(value)								\
 ({												\
-	(task)->thread.flags = (((task)->thread.flags & ~IA64_THREAD_UAC_MASK)			\
+	current->thread.flags = ((current->thread.flags & ~IA64_THREAD_UAC_MASK)			\
 				| (((value) << IA64_THREAD_UAC_SHIFT) & IA64_THREAD_UAC_MASK));	\
 	0;											\
 })
-#define GET_UNALIGN_CTL(task,addr)								\
+#define GET_UNALIGN_CTL(addr)								\
 ({												\
-	put_user(((task)->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT,	\
+	put_user((current->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT,	\
 		 (int __user *) (addr));							\
 })
 
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 2dbe558..b59720f 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -139,17 +139,17 @@ struct thread_struct {
 #define PARISC_UAC_SHIFT	0
 #define PARISC_UAC_MASK		(PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
 
-#define SET_UNALIGN_CTL(task,value)                                       \
+#define SET_UNALIGN_CTL(value)                                            \
         ({                                                                \
-        (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
+        current->thread.flags = ((current->thread.flags & ~PARISC_UAC_MASK) \
                                 | (((value) << PARISC_UAC_SHIFT) &        \
                                    PARISC_UAC_MASK));                     \
         0;                                                                \
         })
 
-#define GET_UNALIGN_CTL(task,addr)                                        \
+#define GET_UNALIGN_CTL(addr)                                             \
         ({                                                                \
-        put_user(((task)->thread.flags & PARISC_UAC_MASK)                 \
+        put_user((current->thread.flags & PARISC_UAC_MASK)                \
                  >> PARISC_UAC_SHIFT, (int __user *) (addr));             \
         })
 
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index e1cd7ec..b8d9306 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -413,11 +413,11 @@ extern int set_fpexc_mode(unsigned int val);
 extern int get_endian(unsigned long adr);
 extern int set_endian(unsigned int val);
 
-#define GET_UNALIGN_CTL(tsk, adr)	get_unalign_ctl((tsk), (adr))
-#define SET_UNALIGN_CTL(tsk, val)	set_unalign_ctl((tsk), (val))
+#define GET_UNALIGN_CTL(adr)	get_unalign_ctl((adr))
+#define SET_UNALIGN_CTL(val)	set_unalign_ctl((val))
 
-extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr);
-extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val);
+extern int get_unalign_ctl(unsigned long adr);
+extern int set_unalign_ctl(unsigned int val);
 
 extern void load_fp_state(struct thread_fp_state *fp);
 extern void store_fp_state(struct thread_fp_state *fp);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 0fcb2f5..17708b7 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -2020,15 +2020,15 @@ int get_endian(unsigned long adr)
 	return put_user(val, (unsigned int __user *)adr);
 }
 
-int set_unalign_ctl(struct task_struct *tsk, unsigned int val)
+int set_unalign_ctl(unsigned int val)
 {
-	tsk->thread.align_ctl = val;
+	current->thread.align_ctl = val;
 	return 0;
 }
 
-int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
+int get_unalign_ctl(unsigned long adr)
 {
-	return put_user(tsk->thread.align_ctl, (unsigned int __user *)adr);
+	return put_user(current->thread.align_ctl, (unsigned int __user *)adr);
 }
 
 static inline int valid_irq_stack(unsigned long sp, struct task_struct *p,
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index 6fbf8c8..ce3d9f6 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -117,11 +117,11 @@ extern void free_thread_xstate(struct task_struct *);
 extern struct kmem_cache *task_xstate_cachep;
 
 /* arch/sh/mm/alignment.c */
-extern int get_unalign_ctl(struct task_struct *, unsigned long addr);
-extern int set_unalign_ctl(struct task_struct *, unsigned int val);
+extern int get_unalign_ctl(unsigned long addr);
+extern int set_unalign_ctl(unsigned int val);
 
-#define GET_UNALIGN_CTL(tsk, addr)	get_unalign_ctl((tsk), (addr))
-#define SET_UNALIGN_CTL(tsk, val)	set_unalign_ctl((tsk), (val))
+#define GET_UNALIGN_CTL(addr)	get_unalign_ctl((addr))
+#define SET_UNALIGN_CTL(val)	set_unalign_ctl((val))
 
 /* arch/sh/mm/init.c */
 extern unsigned int mem_init_done;
diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c
index ec2b253..bad2a31 100644
--- a/arch/sh/mm/alignment.c
+++ b/arch/sh/mm/alignment.c
@@ -80,16 +80,16 @@ unsigned int unaligned_user_action(void)
 	return action;
 }
 
-int get_unalign_ctl(struct task_struct *tsk, unsigned long addr)
+int get_unalign_ctl(unsigned long addr)
 {
-	return put_user(tsk->thread.flags & SH_THREAD_UAC_MASK,
+	return put_user(current->thread.flags & SH_THREAD_UAC_MASK,
 			(unsigned int __user *)addr);
 }
 
-int set_unalign_ctl(struct task_struct *tsk, unsigned int val)
+int set_unalign_ctl(unsigned int val)
 {
-	tsk->thread.flags = (tsk->thread.flags & ~SH_THREAD_UAC_MASK) |
-			    (val & SH_THREAD_UAC_MASK);
+	current->thread.flags = (current->thread.flags & ~SH_THREAD_UAC_MASK) |
+				(val & SH_THREAD_UAC_MASK);
 	return 0;
 }
 
diff --git a/kernel/sys.c b/kernel/sys.c
index 8111c0d..47cf999 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -72,10 +72,10 @@
 #include "uid16.h"
 
 #ifndef SET_UNALIGN_CTL
-# define SET_UNALIGN_CTL(a, b)	(-EINVAL)
+# define SET_UNALIGN_CTL(a)	(-EINVAL)
 #endif
 #ifndef GET_UNALIGN_CTL
-# define GET_UNALIGN_CTL(a, b)	(-EINVAL)
+# define GET_UNALIGN_CTL(a)	(-EINVAL)
 #endif
 
 /*
@@ -2235,10 +2235,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		break;
 
 	case PR_SET_UNALIGN:
-		error = SET_UNALIGN_CTL(me, arg2);
+		error = SET_UNALIGN_CTL(arg2);
 		break;
 	case PR_GET_UNALIGN:
-		error = GET_UNALIGN_CTL(me, arg2);
+		error = GET_UNALIGN_CTL(arg2);
 		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC PATCH 11/11] prctl: Refactor PR_{SET,GET}_UNALIGN to reduce boilerplate
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (9 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 10/11] prctl: Remove redundant task argument from PR_{SET,GET}_UNALIGN backends Dave Martin
@ 2018-05-14 17:14 ` Dave Martin
  2018-05-14 18:28 ` [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Kees Cook
  11 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-14 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Kees Cook, Andrew Morton, Ingo Molnar,
	Richard Henderson, Ivan Kokshaysky, Matt Turner, Tony Luck,
	Fenghua Yu, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Yoshinori Sato, Rich Felker

The PR_SET_UNALIGN and PR_GET_UNALIGN prctl() calls are implemented
by five architectures today, but there is some irregularity and
duplication in the way they are implemented.

This patch moves the common put_user() operation to common code,
since the user pointer type is the same in all cases.

Because this is hardly hot-path code, there is no strong reason to
inline the arch backends for these operations, so this patch also
pushes them down into the arch trees as proper C functions, and
regularises the style of the backends somewhat.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
---
 arch/Kconfig                         |  3 +++
 arch/alpha/Kconfig                   |  1 +
 arch/alpha/include/asm/thread_info.h | 23 -----------------------
 arch/alpha/kernel/Makefile           |  2 +-
 arch/alpha/kernel/sys.c              | 36 ++++++++++++++++++++++++++++++++++++
 arch/ia64/Kconfig                    |  1 +
 arch/ia64/include/asm/processor.h    | 12 ------------
 arch/ia64/kernel/sys_ia64.c          | 15 +++++++++++++++
 arch/parisc/Kconfig                  |  1 +
 arch/parisc/include/asm/processor.h  | 14 --------------
 arch/parisc/kernel/sys_parisc.c      | 15 +++++++++++++++
 arch/powerpc/Kconfig                 |  1 +
 arch/powerpc/include/asm/processor.h |  6 ------
 arch/powerpc/kernel/process.c        |  6 +++---
 arch/sh/Kconfig                      |  1 +
 arch/sh/include/asm/processor.h      |  7 -------
 arch/sh/mm/alignment.c               |  8 ++++----
 include/linux/prctl.h                |  8 ++++++++
 kernel/sys.c                         | 20 ++++++++++----------
 19 files changed, 100 insertions(+), 80 deletions(-)
 create mode 100644 arch/alpha/kernel/sys.c

diff --git a/arch/Kconfig b/arch/Kconfig
index b34b3e8..a9195ffc 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -972,4 +972,7 @@ config REFCOUNT_FULL
 config HAVE_PRCTL_ARCH
 	bool
 
+config HAVE_ARCH_PR_SET_GET_UNALIGN
+	bool
+
 source "kernel/gcov/Kconfig"
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index b202288..afb9aaa 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -23,6 +23,7 @@ config ALPHA
 	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_AUDITSYSCALL
+	select HAVE_ARCH_PR_SET_GET_UNALIGN
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
 	select ODD_RT_SIGACTION
diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index 403b3c8..7ba2099 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -85,28 +85,5 @@ register struct thread_info *__current_thread_info __asm__("$8");
 #define TS_UAC_NOFIX		0x0002	/* ! flags as they match          */
 #define TS_UAC_SIGBUS		0x0004	/* ! userspace part of 'osf_sysinfo' */
 
-#define SET_UNALIGN_CTL(value)	({					\
-	__u32 status = current_thread_info()->status & ~UAC_BITMASK;	\
-	if (value & PR_UNALIGN_NOPRINT)					\
-		status |= TS_UAC_NOPRINT;				\
-	if (value & PR_UNALIGN_SIGBUS)					\
-		status |= TS_UAC_SIGBUS;				\
-	if (value & 4)	/* alpha-specific */				\
-		status |= TS_UAC_NOFIX;					\
-	current_thread_info()->status = status;				\
-	0; })
-
-#define GET_UNALIGN_CTL(value)	({					\
-	__u32 status = current_thread_info()->status & ~UAC_BITMASK;	\
-	__u32 res = 0;							\
-	if (status & TS_UAC_NOPRINT)					\
-		res |= PR_UNALIGN_NOPRINT;				\
-	if (status & TS_UAC_SIGBUS)					\
-		res |= PR_UNALIGN_SIGBUS;				\
-	if (status & TS_UAC_NOFIX)					\
-		res |= 4;						\
-	put_user(res, (int __user *)(value));				\
-	})
-
 #endif /* __KERNEL__ */
 #endif /* _ALPHA_THREAD_INFO_H */
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
index 5a74581..e4b5294 100644
--- a/arch/alpha/kernel/Makefile
+++ b/arch/alpha/kernel/Makefile
@@ -9,7 +9,7 @@ ccflags-y	:= -Wno-sign-compare
 
 obj-y    := entry.o traps.o process.o osf_sys.o irq.o \
 	    irq_alpha.o signal.o setup.o ptrace.o time.o \
-	    systbls.o err_common.o io.o bugs.o
+	    systbls.o err_common.o io.o bugs.o sys.o
 
 obj-$(CONFIG_VGA_HOSE)	+= console.o
 obj-$(CONFIG_SMP)	+= smp.o
diff --git a/arch/alpha/kernel/sys.c b/arch/alpha/kernel/sys.c
new file mode 100644
index 0000000..3dc454f
--- /dev/null
+++ b/arch/alpha/kernel/sys.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/prctl.h>
+#include <linux/thread_info.h>
+#include <linux/uaccess.h>
+
+int arch_set_unalign_ctl(unsigned int val)
+{
+	__u32 status = current_thread_info()->status & ~UAC_BITMASK;
+
+	if (val & PR_UNALIGN_NOPRINT)
+		status |= TS_UAC_NOPRINT;
+	if (val & PR_UNALIGN_SIGBUS)
+		status |= TS_UAC_SIGBUS;
+	if (val & 4)	/* alpha-specific */
+		status |= TS_UAC_NOFIX;
+
+	current_thread_info()->status = status;
+
+	return 0;
+}
+
+int arch_get_unalign_ctl(void)
+{
+	__u32 status = current_thread_info()->status & ~UAC_BITMASK;
+	int res = 0;
+
+	if (status & TS_UAC_NOPRINT)
+		res |= PR_UNALIGN_NOPRINT;
+	if (status & TS_UAC_SIGBUS)
+		res |= PR_UNALIGN_SIGBUS;
+	if (status & TS_UAC_NOFIX)
+		res |= 4;
+
+	return res;
+}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index a673dd7..ab62a57 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -55,6 +55,7 @@ config IA64
 	select ARCH_USE_CMPXCHG_LOCKREF
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_PRCTL_ARCH
+	select HAVE_ARCH_PR_SET_GET_UNALIGN
 	default y
 	help
 	  The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 8d5184f..49f4ef9 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -247,18 +247,6 @@ typedef struct {
 	unsigned long seg;
 } mm_segment_t;
 
-#define SET_UNALIGN_CTL(value)								\
-({												\
-	current->thread.flags = ((current->thread.flags & ~IA64_THREAD_UAC_MASK)			\
-				| (((value) << IA64_THREAD_UAC_SHIFT) & IA64_THREAD_UAC_MASK));	\
-	0;											\
-})
-#define GET_UNALIGN_CTL(addr)								\
-({												\
-	put_user((current->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT,	\
-		 (int __user *) (addr));							\
-})
-
 struct thread_struct {
 	__u32 flags;			/* various thread flags (see IA64_THREAD_*) */
 	/* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
index d996585..2c2fd65 100644
--- a/arch/ia64/kernel/sys_ia64.c
+++ b/arch/ia64/kernel/sys_ia64.c
@@ -206,3 +206,18 @@ int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
 		return -EINVAL;
 	}
 }
+
+int arch_set_unalign_ctl(unsigned int val)
+{
+	current->thread.flags &= ~IA64_THREAD_UAC_MASK;
+	current->thread.flags |= (val << IA64_THREAD_UAC_SHIFT) &
+		IA64_THREAD_UAC_MASK;
+
+	return 0;
+}
+
+int arch_get_unalign_ctl(void)
+{
+	return (current->thread.flags & IA64_THREAD_UAC_MASK) >>
+		IA64_THREAD_UAC_SHIFT;
+}
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index fc5a574..a2f0f0a 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -44,6 +44,7 @@ config PARISC
 	select HAVE_DEBUG_STACKOVERFLOW
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_HASH
+	select HAVE_ARCH_PR_SET_GET_UNALIGN
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select GENERIC_SCHED_CLOCK
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index b59720f..dbea6e9 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -139,20 +139,6 @@ struct thread_struct {
 #define PARISC_UAC_SHIFT	0
 #define PARISC_UAC_MASK		(PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
 
-#define SET_UNALIGN_CTL(value)                                            \
-        ({                                                                \
-        current->thread.flags = ((current->thread.flags & ~PARISC_UAC_MASK) \
-                                | (((value) << PARISC_UAC_SHIFT) &        \
-                                   PARISC_UAC_MASK));                     \
-        0;                                                                \
-        })
-
-#define GET_UNALIGN_CTL(addr)                                             \
-        ({                                                                \
-        put_user((current->thread.flags & PARISC_UAC_MASK)                \
-                 >> PARISC_UAC_SHIFT, (int __user *) (addr));             \
-        })
-
 #define INIT_THREAD { \
 	.regs = {	.gr	= { 0, }, \
 			.fr	= { 0, }, \
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 43b308c..e3a7f29 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -30,6 +30,7 @@
 #include <linux/linkage.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
+#include <linux/prctl.h>
 #include <linux/sched/signal.h>
 #include <linux/sched/mm.h>
 #include <linux/shm.h>
@@ -37,6 +38,7 @@
 #include <linux/utsname.h>
 #include <linux/personality.h>
 #include <linux/random.h>
+#include <asm/processor.h>
 
 /* we construct an artificial offset for the mapping based on the physical
  * address of the kernel mapping variable */
@@ -391,3 +393,16 @@ long parisc_personality(unsigned long personality)
 
 	return err;
 }
+
+int arch_set_unalign_ctl(unsigned int val)
+{
+	current->thread.flags &= ~PARISC_UAC_MASK;
+	current->thread.flags |= (val << PARISC_UAC_SHIFT) & PARISC_UAC_MASK;
+
+	return 0;
+}
+
+int arch_get_unalign_ctl(void)
+{
+	return (current->thread.flags & PARISC_UAC_MASK) >> PARISC_UAC_SHIFT;
+}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b94323e..68c31fb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -181,6 +181,7 @@ config PPC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if COMPAT
+	select HAVE_ARCH_PR_SET_GET_UNALIGN
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_CBPF_JIT			if !PPC64
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index b8d9306..8bac2f6 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -413,12 +413,6 @@ extern int set_fpexc_mode(unsigned int val);
 extern int get_endian(unsigned long adr);
 extern int set_endian(unsigned int val);
 
-#define GET_UNALIGN_CTL(adr)	get_unalign_ctl((adr))
-#define SET_UNALIGN_CTL(val)	set_unalign_ctl((val))
-
-extern int get_unalign_ctl(unsigned long adr);
-extern int set_unalign_ctl(unsigned int val);
-
 extern void load_fp_state(struct thread_fp_state *fp);
 extern void store_fp_state(struct thread_fp_state *fp);
 extern void load_vr_state(struct thread_vr_state *vr);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 17708b7..a623373 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -2020,15 +2020,15 @@ int get_endian(unsigned long adr)
 	return put_user(val, (unsigned int __user *)adr);
 }
 
-int set_unalign_ctl(unsigned int val)
+int arch_set_unalign_ctl(unsigned int val)
 {
 	current->thread.align_ctl = val;
 	return 0;
 }
 
-int get_unalign_ctl(unsigned long adr)
+int arch_get_unalign_ctl(void)
 {
-	return put_user(current->thread.align_ctl, (unsigned int __user *)adr);
+	return current->thread.align_ctl;
 }
 
 static inline int valid_irq_stack(unsigned long sp, struct task_struct *p,
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 97fe293..f9631bf 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -48,6 +48,7 @@ config SUPERH
 	select OLD_SIGSUSPEND
 	select OLD_SIGACTION
 	select HAVE_ARCH_AUDITSYSCALL
+	select HAVE_ARCH_PR_SET_GET_UNALIGN
 	select HAVE_FUTEX_CMPXCHG if FUTEX
 	select HAVE_NMI
 	help
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index ce3d9f6..ff4d332 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -116,13 +116,6 @@ extern unsigned int xstate_size;
 extern void free_thread_xstate(struct task_struct *);
 extern struct kmem_cache *task_xstate_cachep;
 
-/* arch/sh/mm/alignment.c */
-extern int get_unalign_ctl(unsigned long addr);
-extern int set_unalign_ctl(unsigned int val);
-
-#define GET_UNALIGN_CTL(addr)	get_unalign_ctl((addr))
-#define SET_UNALIGN_CTL(val)	set_unalign_ctl((val))
-
 /* arch/sh/mm/init.c */
 extern unsigned int mem_init_done;
 
diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c
index bad2a31..63fc963 100644
--- a/arch/sh/mm/alignment.c
+++ b/arch/sh/mm/alignment.c
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/seq_file.h>
+#include <linux/prctl.h>
 #include <linux/proc_fs.h>
 #include <linux/uaccess.h>
 #include <linux/ratelimit.h>
@@ -80,13 +81,12 @@ unsigned int unaligned_user_action(void)
 	return action;
 }
 
-int get_unalign_ctl(unsigned long addr)
+int arch_get_unalign_ctl(void)
 {
-	return put_user(current->thread.flags & SH_THREAD_UAC_MASK,
-			(unsigned int __user *)addr);
+	return current->thread.flags & SH_THREAD_UAC_MASK;
 }
 
-int set_unalign_ctl(unsigned int val)
+int arch_set_unalign_ctl(unsigned int val)
 {
 	current->thread.flags = (current->thread.flags & ~SH_THREAD_UAC_MASK) |
 				(val & SH_THREAD_UAC_MASK);
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
index 5ce3713..abc803e 100644
--- a/include/linux/prctl.h
+++ b/include/linux/prctl.h
@@ -16,4 +16,12 @@ static inline int prctl_arch(int option, unsigned long arg2,
 }
 #endif
 
+#ifdef CONFIG_HAVE_ARCH_PR_SET_GET_UNALIGN
+extern int arch_set_unalign_ctl(unsigned int val);
+extern int arch_get_unalign_ctl(void);
+#else
+static inline int arch_set_unalign_ctl(unsigned int val) { return -EINVAL; }
+static inline int arch_get_unalign_ctl(void) { return -EINVAL; }
+#endif
+
 #endif /* ! _LINUX_PRCTL_H */
diff --git a/kernel/sys.c b/kernel/sys.c
index 47cf999..562ffbe 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -71,13 +71,6 @@
 
 #include "uid16.h"
 
-#ifndef SET_UNALIGN_CTL
-# define SET_UNALIGN_CTL(a)	(-EINVAL)
-#endif
-#ifndef GET_UNALIGN_CTL
-# define GET_UNALIGN_CTL(a)	(-EINVAL)
-#endif
-
 /*
  * this is where the system-wide overflow UID and GID are defined, for
  * architectures that now have 32-bit UID/GID but didn't in the past
@@ -2235,10 +2228,17 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 		break;
 
 	case PR_SET_UNALIGN:
-		error = SET_UNALIGN_CTL(arg2);
+		error = arch_set_unalign_ctl(arg2);
 		break;
-	case PR_GET_UNALIGN:
-		error = GET_UNALIGN_CTL(arg2);
+	case PR_GET_UNALIGN: {
+		int res;
+
+		res = arch_get_unalign_ctl();
+		if (res >= 0)
+			error = put_user(res, (int __user *)arg2);
+		else
+			error = res;
+		}
 		break;
 	case PR_GET_TIMING:
 		error = PR_TIMING_STATISTICAL;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls
  2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
                   ` (10 preceding siblings ...)
  2018-05-14 17:14 ` [RFC PATCH 11/11] prctl: Refactor PR_{SET,GET}_UNALIGN to reduce boilerplate Dave Martin
@ 2018-05-14 18:28 ` Kees Cook
  2018-05-15 13:30   ` Dave Martin
  11 siblings, 1 reply; 19+ messages in thread
From: Kees Cook @ 2018-05-14 18:28 UTC (permalink / raw)
  To: Dave Martin
  Cc: LKML, linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Matt Turner, Michael Ellerman,
	Paul Mackerras, Ralf Baechle, Richard Henderson, Rich Felker,
	Thomas Gleixner, Tony Luck, Will Deacon, X86 ML, Yoshinori Sato

On Mon, May 14, 2018 at 10:14 AM, Dave Martin <Dave.Martin@arm.com> wrote:
> [Reviewer note: this is a cross-arch series.  To reduce spam, I have
> tried not to Cc people on patches they aren't likely to care about.
> The complete series can be found in the LKML or linux-arch archives.]
>
> The core framework for the prctl() syscall is unloved and looking
> rather crusty these days.  It also relies on defining ancillary
> boilerplate macros for each prctl() in order to control conditional
> compilation of the different prctl calls.  We have better ways to
> do this now.

This is a nice clean-up series, thanks! Some thoughts/comments below...

> This series attempts to modernise the code by defining a couple of new
> Kconfig variables HAVE_PRCTL_ARCH and HAVE_ARCH_PR_SET_GET_UNALIGN to
> allow architectures to provide hooks for arch-dependent prctls.
>
>
> For now this series has had minimal testing: some basic testing of
> arch-specific prctls using PR_SVE_SET_VL on arm64; build-tested on
> x86; otherwise untested.
>
> This is not polished yet... but I'm interested to know what people
> think about the approach.

I'm not entirely convinced the removal of the "task not current"
interface is very useful as I've found myself needing to adjust other
interfaces like this to _add_ the "task not current" logic, but ... I
can't really argue very hard for keeping the task args since nothing
is using them... meh.

I dislike this being named "prctl_arch" when everything else like this
is "arch_foo...", but I do see the collision with the x86-specific
"arch_prctl" syscall. Perhaps it might be better to wire things up
differently, since x86's arch_prctl is actually "sys_arch_prctl" so I
don't think there would be a symbol collision, and maybe the 9 options
could be added to the global prctl list, with the x86 syscall getting
called at the end of the new "arch_prctl"? Then the syscall could get
deprecated in favor of just using prctl directly?

Your new x86 arch_prctl (neé prctl_arch) could be something like:

int arch_prctl(int option, unsigned long arg2, unsigned long arg3,
                     unsigned long arg4, unsigned long arg5)
{
... existing stuff in your series ...
    case ARCH_SET_GS:
    case ARCH_SET_FS:
    case ARCH_GET_GS:
    case ARCH_GET_FS:
    case ARCH_MAP_VDSO_X32:
    case ARCH_MAP_VDSO_32:
    case ARCH_MAP_VDSO_64:
        if (arg3 || arg4 || arg5)
            return -EINVAL;
        return do_arch_prctl_64(current, option, arg2);
    case ARCH_GET_CPUID:
    case ARCH_SET_CPUID:
        if (arg3 || arg4 || arg5)
            return -EINVAL;
        return do_arch_prctl_common(current, option, arg2);
    default:
        return -EINVAL;
    }
}

Or maybe all the logic could get ripped out of
arch/x86/kernel/process*.c and put in arch/x86/kernel/sys.c directly?

Perhaps this is all overkill, but I find it rather annoying that one
arch's weird syscall would block "expected" naming of a cross-arch
interface...

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions
  2018-05-14 17:14 ` [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions Dave Martin
@ 2018-05-15  3:05   ` Michael Ellerman
  0 siblings, 0 replies; 19+ messages in thread
From: Michael Ellerman @ 2018-05-15  3:05 UTC (permalink / raw)
  To: Dave Martin, linux-kernel
  Cc: linux-arch, Benjamin Herrenschmidt, Paul Mackerras

Dave Martin <Dave.Martin@arm.com> writes:

> Some powerpc-specific prctl backends take a task argument that is
> redundant, since the only thing ever passed is "current".
>
> This patch gets rid of the redundant arguments.
>
> No functional change.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/processor.h | 16 ++++++++--------
>  arch/powerpc/kernel/process.c        | 30 +++++++++++++++---------------
>  kernel/sys.c                         | 12 ++++++------
>  3 files changed, 29 insertions(+), 29 deletions(-)

This looks fine. I'm happy for it to get tested in linux-next to shake
out anything subtle.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code
  2018-05-14 17:14 ` [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-15  3:06   ` Michael Ellerman
  0 siblings, 0 replies; 19+ messages in thread
From: Michael Ellerman @ 2018-05-15  3:06 UTC (permalink / raw)
  To: Dave Martin, linux-kernel
  Cc: linux-arch, Benjamin Herrenschmidt, Paul Mackerras

Dave Martin <Dave.Martin@arm.com> writes:

> This patch moves the powerpc-specific prctl call implementations
> out of core code and removes redundant boilerplate associated with
> them.
>
> No functional change.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/Kconfig                 |  1 +
>  arch/powerpc/include/asm/processor.h |  6 ------
>  arch/powerpc/kernel/syscalls.c       | 17 +++++++++++++++++
>  kernel/sys.c                         | 24 ------------------------
>  4 files changed, 18 insertions(+), 30 deletions(-)

This also looks OK to me.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls
  2018-05-14 18:28 ` [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Kees Cook
@ 2018-05-15 13:30   ` Dave Martin
  0 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-15 13:30 UTC (permalink / raw)
  To: Kees Cook
  Cc: LKML, linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Matt Turner, Michael Ellerman,
	Paul Mackerras, Ralf Baechle, Richard Henderson, Rich Felker,
	Thomas Gleixner, Tony Luck, Will Deacon, X86 ML, Yoshinori Sato

On Mon, May 14, 2018 at 07:28:11PM +0100, Kees Cook wrote:
> On Mon, May 14, 2018 at 10:14 AM, Dave Martin <Dave.Martin@arm.com> wrote:
> > [Reviewer note: this is a cross-arch series.  To reduce spam, I have
> > tried not to Cc people on patches they aren't likely to care about.
> > The complete series can be found in the LKML or linux-arch archives.]
> >
> > The core framework for the prctl() syscall is unloved and looking
> > rather crusty these days.  It also relies on defining ancillary
> > boilerplate macros for each prctl() in order to control conditional
> > compilation of the different prctl calls.  We have better ways to
> > do this now.
> 
> This is a nice clean-up series, thanks! Some thoughts/comments below...
> 
> > This series attempts to modernise the code by defining a couple of new
> > Kconfig variables HAVE_PRCTL_ARCH and HAVE_ARCH_PR_SET_GET_UNALIGN to
> > allow architectures to provide hooks for arch-dependent prctls.
> >
> >
> > For now this series has had minimal testing: some basic testing of
> > arch-specific prctls using PR_SVE_SET_VL on arm64; build-tested on
> > x86; otherwise untested.
> >
> > This is not polished yet... but I'm interested to know what people
> > think about the approach.
> 
> I'm not entirely convinced the removal of the "task not current"
> interface is very useful as I've found myself needing to adjust other
> interfaces like this to _add_ the "task not current" logic, but ... I
> can't really argue very hard for keeping the task args since nothing
> is using them... meh.

For operations that are shared with ptrace it does make sense to have a
task argument, but in the end I found it equally natural to put that
only in the backend rather than having it invoked directly with an
explicit argument by the prctl demux.

In the case of PR_SVE_SET_VL the interface has to be massaged in
different ways depending on whether it's being invokved via prctl or
ptrace anyway, so I guess there was no temptation to keep the task
argument on the prctl side in this case.

Ptrace differs from prctl in that in the former case we can assume
the task is stopped and in the latter we can't.  This results in
some conditional local_bh_disable()..local_bh_enable() in
sve_set_vector_length(), which is a bit gross.  Maybe it's best not
to encourage ptrace and prctl to be given the same backend functions
without thinking about it.

(See the different callers of sve_set_vector_length() under arch/arm64/.)


Others' views may differ though, so I'm happy to be overruled on this if
people object.

> I dislike this being named "prctl_arch" when everything else like this
> is "arch_foo...", but I do see the collision with the x86-specific
> "arch_prctl" syscall. Perhaps it might be better to wire things up

Agreed.  Actually, it was originally called arch_prctl(), until I
discovered that it broke um.  x86 seems happy enough, since its
existing arch_prctl() functions all have do_/sys_/etc. prefixes.

> differently, since x86's arch_prctl is actually "sys_arch_prctl" so I
> don't think there would be a symbol collision, and maybe the 9 options
> could be added to the global prctl list, with the x86 syscall getting
> called at the end of the new "arch_prctl"? Then the syscall could get
> deprecated in favor of just using prctl directly?
> 
> Your new x86 arch_prctl (neé prctl_arch) could be something like:
> 
> int arch_prctl(int option, unsigned long arg2, unsigned long arg3,
>                      unsigned long arg4, unsigned long arg5)
> {
> ... existing stuff in your series ...
>     case ARCH_SET_GS:
>     case ARCH_SET_FS:
>     case ARCH_GET_GS:
>     case ARCH_GET_FS:
>     case ARCH_MAP_VDSO_X32:
>     case ARCH_MAP_VDSO_32:
>     case ARCH_MAP_VDSO_64:
>         if (arg3 || arg4 || arg5)
>             return -EINVAL;
>         return do_arch_prctl_64(current, option, arg2);
>     case ARCH_GET_CPUID:
>     case ARCH_SET_CPUID:
>         if (arg3 || arg4 || arg5)
>             return -EINVAL;
>         return do_arch_prctl_common(current, option, arg2);
>     default:
>         return -EINVAL;
>     }
> }

So, you mean we merge x86's arch_prctl() syscall with the generic one,
and have both syscalls from userland invoke the common backend?

That does look kind of feasible, given the compatible ABI and the
fact that there does not appear to be a namespace clash in the option
values.

> Or maybe all the logic could get ripped out of
> arch/x86/kernel/process*.c and put in arch/x86/kernel/sys.c directly?
> 
> Perhaps this is all overkill, but I find it rather annoying that one
> arch's weird syscall would block "expected" naming of a cross-arch
> interface...

I didn't really like overloading the name "arch_prctl" at all, since
this is established as the name of the existing x86 syscall.  Even if
we arrange things in the kernel so that there is no linkage namespace
clash, there seemed to be high risk of confusion.

If we can merge the two (as suggested above) then that might be
acceptable, but I wasn't confident that there were no subtle gotchas
with such an approach...

Thoughts?

Cheers
---Dave

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code
  2018-05-14 17:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin
@ 2018-05-21 18:28   ` Will Deacon
  0 siblings, 0 replies; 19+ messages in thread
From: Will Deacon @ 2018-05-21 18:28 UTC (permalink / raw)
  To: Dave Martin
  Cc: linux-kernel, linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Kees Cook, Matt Turner,
	Michael Ellerman, Paul Mackerras, Ralf Baechle,
	Richard Henderson, Rich Felker, Thomas Gleixner, Tony Luck, x86,
	Yoshinori Sato

Hi Dave,

On Mon, May 14, 2018 at 06:14:17PM +0100, Dave Martin wrote:
> The core framework for the prctl() syscall is unloved and looking
> rather crusty these days.  It also relies on defining ancillary
> boilerplate macros for each prctl() in order to control conditional
> compilation of the different prctl calls.  We have better ways to
> do this now, using Kconfig.
> 
> This patch defines a new arch hook arch_syscall().  Architectures
> that implemement arch-specific syscalls can now select
> HAVE_ARCH_SYSCALL in their Kconfig and define this function
> appropriately.
> 
> The core prctl() implementation now matches option against the list
> of common or legacy prctls, deferring to prctl_arch() if an
> unrecognised option is encountered.
> 
> (arch_prctl() would have been a nicer name, but it conflicts with the
> pre-existing syscall of the same name on x86, particularly in the um
> code.)
> 
> No functional change.

[...]

> diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
> index af5f8c2..c911ff0 100644
> --- a/include/uapi/linux/prctl.h
> +++ b/include/uapi/linux/prctl.h
> @@ -1,6 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> -#ifndef _LINUX_PRCTL_H
> -#define _LINUX_PRCTL_H
> +#ifndef _UAPI_LINUX_PRCTL_H
> +#define _UAPI_LINUX_PRCTL_H

Is it safe to rename this #define, or is there a possibility that userspace
could be using it for something and relying on it not changing?

Other than that:

Acked-by: Will Deacon <will.deacon@arm.com>

Will

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code
  2018-05-14 17:14 ` [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code Dave Martin
@ 2018-05-21 18:30   ` Will Deacon
  0 siblings, 0 replies; 19+ messages in thread
From: Will Deacon @ 2018-05-21 18:30 UTC (permalink / raw)
  To: Dave Martin; +Cc: linux-kernel, linux-arch, Catalin Marinas, marc.zyngier

On Mon, May 14, 2018 at 06:14:18PM +0100, Dave Martin wrote:
> This patch moves the arm64-specific prctl call implementations out
> of core code and removes redundant boilerplate associated with
> them.
> 
> No functional change.
> 
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/Kconfig                 |  1 +
>  arch/arm64/include/asm/processor.h |  4 ----
>  arch/arm64/kernel/sys.c            | 15 +++++++++++++++
>  kernel/sys.c                       | 12 ------------
>  4 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index eb2cf49..6b706af 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -123,6 +123,7 @@ config ARM64
>  	select HAVE_PERF_EVENTS
>  	select HAVE_PERF_REGS
>  	select HAVE_PERF_USER_STACK_DUMP
> +	select HAVE_PRCTL_ARCH
>  	select HAVE_REGS_AND_STACK_ACCESS_API
>  	select HAVE_RCU_TABLE_FREE
>  	select HAVE_SYSCALL_TRACEPOINTS
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 7675989..b1d262f 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -244,9 +244,5 @@ void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused);
>  void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused);
>  void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused);
>  
> -/* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */
> -#define SVE_SET_VL(arg)	sve_set_current_vl(arg)
> -#define SVE_GET_VL()	sve_get_current_vl()
> -
>  #endif /* __ASSEMBLY__ */
>  #endif /* __ASM_PROCESSOR_H */
> diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
> index 72981ba..597ff35 100644
> --- a/arch/arm64/kernel/sys.c
> +++ b/arch/arm64/kernel/sys.c
> @@ -22,10 +22,12 @@
>  #include <linux/fs.h>
>  #include <linux/mm.h>
>  #include <linux/export.h>
> +#include <linux/prctl.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>
>  #include <linux/syscalls.h>
>  #include <asm/cpufeature.h>
> +#include <asm/fpsimd.h>
>  
>  asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
>  			 unsigned long prot, unsigned long flags,
> @@ -45,6 +47,19 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
>  	return sys_personality(personality);
>  }
>  
> +int prctl_arch(int option, unsigned long arg2, unsigned long arg3,
> +	       unsigned long arg4, unsigned long arg5)
> +{
> +	switch (option) {
> +	case PR_SVE_SET_VL:
> +		return sve_set_current_vl(arg2);
> +	case PR_SVE_GET_VL:
> +		return sve_get_current_vl();
> +	default:
> +		return -EINVAL;
> +	}
> +}

If we think this might grow, then it might be worth adding a prctl.c to
collect these together. Anyhow:

Acked-by: Will Deacon <will.deacon@arm.com>

Will

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code
       [not found] <5252accbd67022cea25e5aa80e48d95c.localhost>
@ 2018-05-23 10:14 ` Dave Martin
  0 siblings, 0 replies; 19+ messages in thread
From: Dave Martin @ 2018-05-23 10:14 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, linux-arch, Andrew Morton, Benjamin Herrenschmidt,
	Catalin Marinas, Fenghua Yu, H. Peter Anvin, Ingo Molnar,
	Ivan Kokshaysky, James Hogan, Kees Cook, Matt Turner,
	Michael Ellerman, Paul Mackerras, Ralf Baechle,
	Richard Henderson, Rich Felker, Thomas Gleixner, Tony Luck, x86,
	Yoshinori Sato

On Mon, May 21, 2018 at 07:28:26PM +0100, Will Deacon wrote:
> Hi Dave,
> 
> On Mon, May 14, 2018 at 06:14:17PM +0100, Dave Martin wrote:
> > The core framework for the prctl() syscall is unloved and looking
> > rather crusty these days.  It also relies on defining ancillary
> > boilerplate macros for each prctl() in order to control conditional
> > compilation of the different prctl calls.  We have better ways to
> > do this now, using Kconfig.
> > 
> > This patch defines a new arch hook arch_syscall().  Architectures
> > that implemement arch-specific syscalls can now select
> > HAVE_ARCH_SYSCALL in their Kconfig and define this function
> > appropriately.
> > 
> > The core prctl() implementation now matches option against the list
> > of common or legacy prctls, deferring to prctl_arch() if an
> > unrecognised option is encountered.
> > 
> > (arch_prctl() would have been a nicer name, but it conflicts with the
> > pre-existing syscall of the same name on x86, particularly in the um
> > code.)
> > 
> > No functional change.
> 
> [...]
> 
> > diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
> > index af5f8c2..c911ff0 100644
> > --- a/include/uapi/linux/prctl.h
> > +++ b/include/uapi/linux/prctl.h
> > @@ -1,6 +1,6 @@
> >  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > -#ifndef _LINUX_PRCTL_H
> > -#define _LINUX_PRCTL_H
> > +#ifndef _UAPI_LINUX_PRCTL_H
> > +#define _UAPI_LINUX_PRCTL_H
> 
> Is it safe to rename this #define, or is there a possibility that userspace
> could be using it for something and relying on it not changing?
> 
> Other than that:
> 
> Acked-by: Will Deacon <will.deacon@arm.com>

I think that header guards are generally viewed as being private to a
project and not API.  codesearch.debian.net yields few hits, where there
are actual #ifdefs on this symbol, they seem to be pastes of the kernel
headers:

https://codesearch.debian.net/search?q=_LINUX_PRCTL_H&perpkg=1

 -> android, linux, dietlibc ... gnome-chess (?)


There is plenty of precedent in the Howells special:

607ca46e97a1 ("UAPI: (Scripted) Disintegrate include/linux")

See for example <{,uapi/}linux/loop.h>.

Cheers
---Dave

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-05-23 10:15 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 17:14 [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Dave Martin
2018-05-14 17:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin
2018-05-21 18:28   ` Will Deacon
2018-05-14 17:14 ` [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code Dave Martin
2018-05-21 18:30   ` Will Deacon
2018-05-14 17:14 ` [RFC PATCH 03/11] MIPS: Remove unused task argument from prctl functions Dave Martin
2018-05-14 17:14 ` [RFC PATCH 04/11] MIPS: Move arch-specific prctls out of core code Dave Martin
2018-05-14 17:14 ` [RFC PATCH 05/11] x86: " Dave Martin
2018-05-14 17:14 ` [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions Dave Martin
2018-05-15  3:05   ` Michael Ellerman
2018-05-14 17:14 ` [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code Dave Martin
2018-05-15  3:06   ` Michael Ellerman
2018-05-14 17:14 ` [RFC PATCH 08/11] ia64: Remove unused task argument from prctl functions Dave Martin
2018-05-14 17:14 ` [RFC PATCH 09/11] ia64: Move arch-specific prctls out of core code Dave Martin
2018-05-14 17:14 ` [RFC PATCH 10/11] prctl: Remove redundant task argument from PR_{SET,GET}_UNALIGN backends Dave Martin
2018-05-14 17:14 ` [RFC PATCH 11/11] prctl: Refactor PR_{SET,GET}_UNALIGN to reduce boilerplate Dave Martin
2018-05-14 18:28 ` [RFC PATCH 00/11] prctl: Modernise wiring for optional prctl() calls Kees Cook
2018-05-15 13:30   ` Dave Martin
     [not found] <5252accbd67022cea25e5aa80e48d95c.localhost>
2018-05-23 10:14 ` [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Dave Martin

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