aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@ezchip.com>2015-07-22 14:30:14 -0400
committerChris Metcalf <cmetcalf@ezchip.com>2015-07-30 12:32:16 -0400
commita0ddef81f4aeeeec3326f6b6a255d8ea13b41908 (patch)
tree3a551abb0a57ff62fa7ad380f87e6c8bdb154d7b /arch/tile
parent38715df206d52817ac8ac032f35ee76955bdc15d (diff)
tile: enable full SECCOMP support
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Diffstat (limited to 'arch/tile')
-rw-r--r--arch/tile/Kconfig17
-rw-r--r--arch/tile/include/asm/Kbuild1
-rw-r--r--arch/tile/include/asm/elf.h4
-rw-r--r--arch/tile/include/asm/syscall.h28
-rw-r--r--arch/tile/kernel/intvec_32.S1
-rw-r--r--arch/tile/kernel/intvec_64.S1
-rw-r--r--arch/tile/kernel/ptrace.c3
7 files changed, 51 insertions, 4 deletions
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 9def1f52d03a..2ba12d761723 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -32,6 +32,7 @@ config TILE
32 select EDAC_SUPPORT 32 select EDAC_SUPPORT
33 select GENERIC_STRNCPY_FROM_USER 33 select GENERIC_STRNCPY_FROM_USER
34 select GENERIC_STRNLEN_USER 34 select GENERIC_STRNLEN_USER
35 select HAVE_ARCH_SECCOMP_FILTER
35 36
36# FIXME: investigate whether we need/want these options. 37# FIXME: investigate whether we need/want these options.
37# select HAVE_IOREMAP_PROT 38# select HAVE_IOREMAP_PROT
@@ -221,6 +222,22 @@ config COMPAT
221 If enabled, the kernel will support running TILE-Gx binaries 222 If enabled, the kernel will support running TILE-Gx binaries
222 that were built with the -m32 option. 223 that were built with the -m32 option.
223 224
225config SECCOMP
226 bool "Enable seccomp to safely compute untrusted bytecode"
227 depends on PROC_FS
228 help
229 This kernel feature is useful for number crunching applications
230 that may need to compute untrusted bytecode during their
231 execution. By using pipes or other transports made available to
232 the process as file descriptors supporting the read/write
233 syscalls, it's possible to isolate those applications in
234 their own address space using seccomp. Once seccomp is
235 enabled via prctl, it cannot be disabled and the task is only
236 allowed to execute a few safe syscalls defined by each seccomp
237 mode.
238
239 If unsure, say N.
240
224config SYSVIPC_COMPAT 241config SYSVIPC_COMPAT
225 def_bool y 242 def_bool y
226 depends on COMPAT && SYSVIPC 243 depends on COMPAT && SYSVIPC
diff --git a/arch/tile/include/asm/Kbuild b/arch/tile/include/asm/Kbuild
index d8a843163471..ba35c41c71ff 100644
--- a/arch/tile/include/asm/Kbuild
+++ b/arch/tile/include/asm/Kbuild
@@ -28,6 +28,7 @@ generic-y += poll.h
28generic-y += posix_types.h 28generic-y += posix_types.h
29generic-y += preempt.h 29generic-y += preempt.h
30generic-y += resource.h 30generic-y += resource.h
31generic-y += seccomp.h
31generic-y += sembuf.h 32generic-y += sembuf.h
32generic-y += serial.h 33generic-y += serial.h
33generic-y += shmbuf.h 34generic-y += shmbuf.h
diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h
index 41d9878a9686..c505d77e4d06 100644
--- a/arch/tile/include/asm/elf.h
+++ b/arch/tile/include/asm/elf.h
@@ -22,6 +22,7 @@
22#include <arch/chip.h> 22#include <arch/chip.h>
23 23
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/elf-em.h>
25#include <asm/byteorder.h> 26#include <asm/byteorder.h>
26#include <asm/page.h> 27#include <asm/page.h>
27 28
@@ -30,9 +31,6 @@ typedef unsigned long elf_greg_t;
30#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t)) 31#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
31typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 32typedef elf_greg_t elf_gregset_t[ELF_NGREG];
32 33
33#define EM_TILEPRO 188
34#define EM_TILEGX 191
35
36/* Provide a nominal data structure. */ 34/* Provide a nominal data structure. */
37#define ELF_NFPREG 0 35#define ELF_NFPREG 0
38typedef double elf_fpreg_t; 36typedef double elf_fpreg_t;
diff --git a/arch/tile/include/asm/syscall.h b/arch/tile/include/asm/syscall.h
index 9644b88f133d..373d73064ea1 100644
--- a/arch/tile/include/asm/syscall.h
+++ b/arch/tile/include/asm/syscall.h
@@ -20,6 +20,8 @@
20 20
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/audit.h>
24#include <linux/compat.h>
23#include <arch/abi.h> 25#include <arch/abi.h>
24 26
25/* The array of function pointers for syscalls. */ 27/* The array of function pointers for syscalls. */
@@ -61,7 +63,15 @@ static inline void syscall_set_return_value(struct task_struct *task,
61 struct pt_regs *regs, 63 struct pt_regs *regs,
62 int error, long val) 64 int error, long val)
63{ 65{
64 regs->regs[0] = (long) error ?: val; 66 if (error) {
67 /* R0 is the passed-in negative error, R1 is positive. */
68 regs->regs[0] = error;
69 regs->regs[1] = -error;
70 } else {
71 /* R1 set to zero to indicate no error. */
72 regs->regs[0] = val;
73 regs->regs[1] = 0;
74 }
65} 75}
66 76
67static inline void syscall_get_arguments(struct task_struct *task, 77static inline void syscall_get_arguments(struct task_struct *task,
@@ -82,4 +92,20 @@ static inline void syscall_set_arguments(struct task_struct *task,
82 memcpy(&regs[i], args, n * sizeof(args[0])); 92 memcpy(&regs[i], args, n * sizeof(args[0]));
83} 93}
84 94
95/*
96 * We don't care about endianness (__AUDIT_ARCH_LE bit) here because
97 * tile has the same system calls both on little- and big- endian.
98 */
99static inline int syscall_get_arch(void)
100{
101 if (is_compat_task())
102 return AUDIT_ARCH_TILEGX32;
103
104#ifdef CONFIG_TILEGX
105 return AUDIT_ARCH_TILEGX;
106#else
107 return AUDIT_ARCH_TILEPRO;
108#endif
109}
110
85#endif /* _ASM_TILE_SYSCALL_H */ 111#endif /* _ASM_TILE_SYSCALL_H */
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index cdbda45a4e4b..fbbe2ea882ea 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -1224,6 +1224,7 @@ handle_syscall:
1224 jal do_syscall_trace_enter 1224 jal do_syscall_trace_enter
1225 } 1225 }
1226 FEEDBACK_REENTER(handle_syscall) 1226 FEEDBACK_REENTER(handle_syscall)
1227 blz r0, .Lsyscall_sigreturn_skip
1227 1228
1228 /* 1229 /*
1229 * We always reload our registers from the stack at this 1230 * We always reload our registers from the stack at this
diff --git a/arch/tile/kernel/intvec_64.S b/arch/tile/kernel/intvec_64.S
index 800b91d3f9dc..58964d209d4d 100644
--- a/arch/tile/kernel/intvec_64.S
+++ b/arch/tile/kernel/intvec_64.S
@@ -1247,6 +1247,7 @@ handle_syscall:
1247 jal do_syscall_trace_enter 1247 jal do_syscall_trace_enter
1248 } 1248 }
1249 FEEDBACK_REENTER(handle_syscall) 1249 FEEDBACK_REENTER(handle_syscall)
1250 bltz r0, .Lsyscall_sigreturn_skip
1250 1251
1251 /* 1252 /*
1252 * We always reload our registers from the stack at this 1253 * We always reload our registers from the stack at this
diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index f84eed8243da..bdc126faf741 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -262,6 +262,9 @@ int do_syscall_trace_enter(struct pt_regs *regs)
262 if (work & _TIF_NOHZ) 262 if (work & _TIF_NOHZ)
263 user_exit(); 263 user_exit();
264 264
265 if (secure_computing() == -1)
266 return -1;
267
265 if (work & _TIF_SYSCALL_TRACE) { 268 if (work & _TIF_SYSCALL_TRACE) {
266 if (tracehook_report_syscall_entry(regs)) 269 if (tracehook_report_syscall_entry(regs))
267 regs->regs[TREG_SYSCALL_NR] = -1; 270 regs->regs[TREG_SYSCALL_NR] = -1;