Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/seccomp: add support for system call filtering using BPF

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
c63cb468 e206d3da

+17 -1
+1
arch/s390/Kconfig
··· 124 124 select GENERIC_TIME_VSYSCALL 125 125 select GENERIC_CLOCKEVENTS 126 126 select KTIME_SCALAR if 32BIT 127 + select HAVE_ARCH_SECCOMP_FILTER 127 128 128 129 config SCHED_OMIT_FRAME_POINTER 129 130 def_bool y
+10
arch/s390/include/asm/syscall.h
··· 12 12 #ifndef _ASM_SYSCALL_H 13 13 #define _ASM_SYSCALL_H 1 14 14 15 + #include <linux/audit.h> 15 16 #include <linux/sched.h> 16 17 #include <linux/err.h> 17 18 #include <asm/ptrace.h> ··· 88 87 regs->orig_gpr2 = args[0]; 89 88 } 90 89 90 + static inline int syscall_get_arch(struct task_struct *task, 91 + struct pt_regs *regs) 92 + { 93 + #ifdef CONFIG_COMPAT 94 + if (test_tsk_thread_flag(task, TIF_31BIT)) 95 + return AUDIT_ARCH_S390; 96 + #endif 97 + return sizeof(long) == 8 ? AUDIT_ARCH_S390X : AUDIT_ARCH_S390; 98 + } 91 99 #endif /* _ASM_SYSCALL_H */
+6 -1
arch/s390/kernel/ptrace.c
··· 719 719 long ret = 0; 720 720 721 721 /* Do the secure computing check first. */ 722 - secure_computing_strict(regs->gprs[2]); 722 + if (secure_computing(regs->gprs[2])) { 723 + /* seccomp failures shouldn't expose any additional code. */ 724 + ret = -1; 725 + goto out; 726 + } 723 727 724 728 /* 725 729 * The sysc_tracesys code in entry.S stored the system ··· 749 745 regs->gprs[2], regs->orig_gpr2, 750 746 regs->gprs[3], regs->gprs[4], 751 747 regs->gprs[5]); 748 + out: 752 749 return ret ?: regs->gprs[2]; 753 750 } 754 751