Skip to content

Commit

Permalink
sh: Add SECCOMP_FILTER
Browse files Browse the repository at this point in the history
Port sh to use the new SECCOMP_FILTER code.

Signed-off-by: Michael Karcher <[email protected]>
Tested-by: John Paul Adrian Glaubitz <[email protected]>
Signed-off-by: Rich Felker <[email protected]>
  • Loading branch information
Michael Karcher authored and Rich Felker committed Aug 15, 2020
1 parent 9d2ec8f commit 0bb605c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ config SUPERH
select GUP_GET_PTE_LOW_HIGH if X2TLB
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_KGDB
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ARCH_TRACEHOOK
select HAVE_COPY_THREAD_TLS
select HAVE_DEBUG_BUGVERBOSE
Expand Down
2 changes: 2 additions & 0 deletions arch/sh/kernel/entry-common.S
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ syscall_trace_entry:
mov.l 7f, r11 ! Call do_syscall_trace_enter which notifies
jsr @r11 ! superior (will chomp R[0-7])
nop
cmp/eq #-1, r0
bt syscall_exit
mov.l r0, @(OFF_R0,r15) ! Save return value
! Reload R0-R4 from kernel stack, where the
! parent may have modified them using
Expand Down
5 changes: 3 additions & 2 deletions arch/sh/kernel/ptrace_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,6 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
{
long ret = 0;

secure_computing_strict(regs->regs[0]);

if (test_thread_flag(TIF_SYSCALL_TRACE) &&
tracehook_report_syscall_entry(regs))
/*
Expand All @@ -496,6 +494,9 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
*/
ret = -1L;

if (secure_computing() == -1)
return -1;

if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
trace_sys_enter(regs, regs->regs[0]);

Expand Down
8 changes: 7 additions & 1 deletion tools/testing/selftests/seccomp/seccomp_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ struct seccomp_data {
# define __NR_seccomp 358
# elif defined(__s390__)
# define __NR_seccomp 348
# elif defined(__sh__)
# define __NR_seccomp 372
# else
# warning "seccomp syscall number unknown for this architecture"
# define __NR_seccomp 0xffff
Expand Down Expand Up @@ -1622,6 +1624,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
# define SYSCALL_SYSCALL_NUM regs[4]
# define SYSCALL_RET regs[2]
# define SYSCALL_NUM_RET_SHARE_REG
#elif defined(__sh__)
# define ARCH_REGS struct pt_regs
# define SYSCALL_NUM gpr[3]
# define SYSCALL_RET gpr[0]
#else
# error "Do not know how to find your architecture's registers and syscalls"
#endif
Expand Down Expand Up @@ -1693,7 +1699,7 @@ void change_syscall(struct __test_metadata *_metadata,
EXPECT_EQ(0, ret) {}

#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
defined(__s390__) || defined(__hppa__) || defined(__riscv)
defined(__s390__) || defined(__hppa__) || defined(__riscv) || defined(__sh__)
{
regs.SYSCALL_NUM = syscall;
}
Expand Down

0 comments on commit 0bb605c

Please sign in to comment.