rebase riscv SECCOMP patch

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2019-10-19 19:23:07 +03:00
parent cc8f20e6e3
commit 43ab4ee9d7
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
1 changed files with 27 additions and 19 deletions

View File

@ -1,23 +1,31 @@
From 0cb0b507d7eaff090b2607799de3acad464fa446 Mon Sep 17 00:00:00 2001 From 269ef272b24c852a52deb5b119d4f1744108b5b8 Mon Sep 17 00:00:00 2001
From: David Abdurachmanov <david.abdurachmanov@sifive.com> From: Fedora Kernel Team <kernel-team@fedoraproject.org>
Date: Mon, 24 Jun 2019 18:58:45 +0300 Date: Sat, 19 Oct 2019 16:20:51 +0000
Subject: [PATCH] riscv: add SECCOMP support Subject: [PATCH] riscv: add support for SECCOMP
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com> ---
arch/riscv/Kconfig | 14 ++++++++++
arch/riscv/include/asm/seccomp.h | 10 +++++++
arch/riscv/include/asm/thread_info.h | 5 +++-
arch/riscv/kernel/entry.S | 27 +++++++++++++++++--
arch/riscv/kernel/ptrace.c | 10 +++++++
tools/testing/selftests/seccomp/seccomp_bpf.c | 8 +++++-
6 files changed, 70 insertions(+), 4 deletions(-)
create mode 100644 arch/riscv/include/asm/seccomp.h
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 0c4b12205632..6f89a83c1e9c 100644 index 391b191..b3650f1 100644
--- a/arch/riscv/Kconfig --- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig
@@ -30,6 +30,7 @@ config RISCV @@ -31,6 +31,7 @@ config RISCV
select GENERIC_SMP_IDLE_THREAD select GENERIC_SMP_IDLE_THREAD
select GENERIC_ATOMIC64 if !64BIT select GENERIC_ATOMIC64 if !64BIT
select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_AUDITSYSCALL
+ select HAVE_ARCH_SECCOMP_FILTER + select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ASM_MODVERSIONS
select HAVE_MEMBLOCK_NODE_MAP select HAVE_MEMBLOCK_NODE_MAP
select HAVE_DMA_CONTIGUOUS select HAVE_DMA_CONTIGUOUS
select HAVE_FUTEX_CMPXCHG if FUTEX @@ -272,6 +273,19 @@ menu "Kernel features"
@@ -223,6 +224,19 @@ menu "Kernel features"
source "kernel/Kconfig.hz" source "kernel/Kconfig.hz"
@ -39,7 +47,7 @@ index 0c4b12205632..6f89a83c1e9c 100644
menu "Boot options" menu "Boot options"
diff --git a/arch/riscv/include/asm/seccomp.h b/arch/riscv/include/asm/seccomp.h diff --git a/arch/riscv/include/asm/seccomp.h b/arch/riscv/include/asm/seccomp.h
new file mode 100644 new file mode 100644
index 000000000000..bf7744ee3b3d index 0000000..bf7744e
--- /dev/null --- /dev/null
+++ b/arch/riscv/include/asm/seccomp.h +++ b/arch/riscv/include/asm/seccomp.h
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
@ -54,7 +62,7 @@ index 000000000000..bf7744ee3b3d
+ +
+#endif /* _ASM_SECCOMP_H */ +#endif /* _ASM_SECCOMP_H */
diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/asm/thread_info.h
index 905372d7eeb8..a0b2a29a0da1 100644 index 905372d..a0b2a29 100644
--- a/arch/riscv/include/asm/thread_info.h --- a/arch/riscv/include/asm/thread_info.h
+++ b/arch/riscv/include/asm/thread_info.h +++ b/arch/riscv/include/asm/thread_info.h
@@ -75,6 +75,7 @@ struct thread_info { @@ -75,6 +75,7 @@ struct thread_info {
@ -81,10 +89,10 @@ index 905372d7eeb8..a0b2a29a0da1 100644
#endif /* _ASM_RISCV_THREAD_INFO_H */ #endif /* _ASM_RISCV_THREAD_INFO_H */
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
index bc7a56e1ca6f..0bbedfa3e47d 100644 index 8ca4798..c68b987 100644
--- a/arch/riscv/kernel/entry.S --- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S
@@ -203,8 +203,25 @@ check_syscall_nr: @@ -226,8 +226,25 @@ check_syscall_nr:
/* Check to make sure we don't jump to a bogus syscall number. */ /* Check to make sure we don't jump to a bogus syscall number. */
li t0, __NR_syscalls li t0, __NR_syscalls
la s0, sys_ni_syscall la s0, sys_ni_syscall
@ -112,7 +120,7 @@ index bc7a56e1ca6f..0bbedfa3e47d 100644
la s0, sys_call_table la s0, sys_call_table
slli t0, a7, RISCV_LGPTR slli t0, a7, RISCV_LGPTR
add s0, s0, t0 add s0, s0, t0
@@ -215,6 +232,12 @@ check_syscall_nr: @@ -238,6 +255,12 @@ check_syscall_nr:
ret_from_syscall: ret_from_syscall:
/* Set user a0 to kernel a0 */ /* Set user a0 to kernel a0 */
REG_S a0, PT_A0(sp) REG_S a0, PT_A0(sp)
@ -126,7 +134,7 @@ index bc7a56e1ca6f..0bbedfa3e47d 100644
REG_L t0, TASK_TI_FLAGS(tp) REG_L t0, TASK_TI_FLAGS(tp)
andi t0, t0, _TIF_SYSCALL_WORK andi t0, t0, _TIF_SYSCALL_WORK
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index 368751438366..63e47c9f85f0 100644 index 3687514..63e47c9 100644
--- a/arch/riscv/kernel/ptrace.c --- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c +++ b/arch/riscv/kernel/ptrace.c
@@ -154,6 +154,16 @@ void do_syscall_trace_enter(struct pt_regs *regs) @@ -154,6 +154,16 @@ void do_syscall_trace_enter(struct pt_regs *regs)
@ -147,7 +155,7 @@ index 368751438366..63e47c9f85f0 100644
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
trace_sys_enter(regs, syscall_get_nr(current, regs)); trace_sys_enter(regs, syscall_get_nr(current, regs));
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index dc66fe852768..e30864b25fb5 100644 index 7f8b5c8..69bd454 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -112,6 +112,8 @@ struct seccomp_data { @@ -112,6 +112,8 @@ struct seccomp_data {
@ -159,7 +167,7 @@ index dc66fe852768..e30864b25fb5 100644
# elif defined(__hppa__) # elif defined(__hppa__)
# define __NR_seccomp 338 # define __NR_seccomp 338
# elif defined(__powerpc__) # elif defined(__powerpc__)
@@ -1582,6 +1584,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) @@ -1587,6 +1589,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
# define ARCH_REGS struct user_pt_regs # define ARCH_REGS struct user_pt_regs
# define SYSCALL_NUM regs[8] # define SYSCALL_NUM regs[8]
# define SYSCALL_RET regs[0] # define SYSCALL_RET regs[0]
@ -170,7 +178,7 @@ index dc66fe852768..e30864b25fb5 100644
#elif defined(__hppa__) #elif defined(__hppa__)
# define ARCH_REGS struct user_regs_struct # define ARCH_REGS struct user_regs_struct
# define SYSCALL_NUM gr[20] # define SYSCALL_NUM gr[20]
@@ -1671,7 +1677,7 @@ void change_syscall(struct __test_metadata *_metadata, @@ -1676,7 +1682,7 @@ void change_syscall(struct __test_metadata *_metadata,
EXPECT_EQ(0, ret) {} EXPECT_EQ(0, ret) {}
#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \ #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
@ -180,5 +188,5 @@ index dc66fe852768..e30864b25fb5 100644
regs.SYSCALL_NUM = syscall; regs.SYSCALL_NUM = syscall;
} }
-- --
2.21.0 2.23.0