lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 May 2018 18:14:17 +0100
From:   Dave Martin <Dave.Martin@....com>
To:     linux-kernel@...r.kernel.org
Cc:     linux-arch@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Fenghua Yu <fenghua.yu@...el.com>,
        "H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...nel.org>,
        Ivan Kokshaysky <ink@...assic.park.msu.ru>,
        James Hogan <jhogan@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Matt Turner <mattst88@...il.com>,
        Michael Ellerman <mpe@...erman.id.au>,
        Paul Mackerras <paulus@...ba.org>,
        Ralf Baechle <ralf@...ux-mips.org>,
        Richard Henderson <rth@...ddle.net>,
        Rich Felker <dalias@...c.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Tony Luck <tony.luck@...el.com>,
        Will Deacon <will.deacon@....com>, x86@...nel.org,
        Yoshinori Sato <ysato@...rs.sourceforge.jp>
Subject: [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code

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@....com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Fenghua Yu <fenghua.yu@...el.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Ivan Kokshaysky <ink@...assic.park.msu.ru>
Cc: James Hogan <jhogan@...nel.org>
Cc: Kees Cook <keescook@...omium.org>
Cc: Matt Turner <mattst88@...il.com>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Ralf Baechle <ralf@...ux-mips.org>
Cc: Richard Henderson <rth@...ddle.net>
Cc: Rich Felker <dalias@...c.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Tony Luck <tony.luck@...el.com>
Cc: Will Deacon <will.deacon@....com>
Cc: x86@...nel.org
Cc: Yoshinori Sato <ysato@...rs.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ