seccomp: add bitmap cache support on remaining arches and report cache in procfs
cover seccomp: add bitmap cache support on remaining arches and report cache in procfs
From: YiFei Zhu <[email protected]>
This patch series enables bitmap cache for the remaining arches with SECCOMP_FILTER, other than MIPS.
I was unable to find any of the arches having subarch-specific NR_syscalls macros, so generic NR_syscalls is used. SH's syscall_get_arch seems to only have the 32-bit subarch implementation. I'm not sure if this is expected.
This series has not been tested; I have not built all the cross compilers necessary to build test, let alone run the kernel or benchmark the performance, so help on making sure the bitmap cache works as expected would be appreciated. The series applies on top of Kees's for-next/seccomp branch.
YiFei Zhu (8):
csky: Enable seccomp architecture tracking
parisc: Enable seccomp architecture tracking
powerpc: Enable seccomp architecture tracking
riscv: Enable seccomp architecture tracking
s390: Enable seccomp architecture tracking
sh: Enable seccomp architecture tracking
xtensa: Enable seccomp architecture tracking seccomp/cache: Report cache data through /proc/pid/seccomp_cache
arch/Kconfig | 15 ++++++++ arch/csky/include/asm/Kbuild | 1 - arch/csky/include/asm/seccomp.h | 11 ++++++ arch/parisc/include/asm/Kbuild | 1 - arch/parisc/include/asm/seccomp.h | 22 +++++++++++ arch/powerpc/include/asm/seccomp.h | 21 +++++++++++ arch/riscv/include/asm/seccomp.h | 10 +++++ arch/s390/include/asm/seccomp.h | 9 +++++ arch/sh/include/asm/seccomp.h | 10 +++++ arch/xtensa/include/asm/Kbuild | 1 - arch/xtensa/include/asm/seccomp.h | 11 ++++++ fs/proc/base.c | 6 +++ include/linux/seccomp.h | 7 ++++ kernel/seccomp.c | 59 ++++++++++++++++++++++++++++++ 14 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 arch/csky/include/asm/seccomp.h create mode 100644 arch/parisc/include/asm/seccomp.h create mode 100644 arch/xtensa/include/asm/seccomp.h
base-commit: 38c37e8fd3d2590c4234d8cfbc22158362f0eb04 --
2.29.2
PATCH 1/8 csky: Enable seccomp architecture tracking
From: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for csky.
--- arch/csky/include/asm/Kbuild | 1 - arch/csky/include/asm/seccomp.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 arch/csky/include/asm/seccomp.h
arch/csky/include/asm/Kbuild +0 -1
@@ -4,6 +4,5 @@ generic-y += gpio.h generic-y += kvm_para.h generic-y += local64.h generic-y += qrwlock.h -generic-y += seccomp.h generic-y += user.h generic-y += vmlinux.lds.h
arch/csky/include/asm/seccomp.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_SECCOMP_H +#define _ASM_SECCOMP_H + +#include <asm-generic/seccomp.h> + +#define SECCOMP_ARCH_NATIVE AUDIT_ARCH_CSKY +#define SECCOMP_ARCH_NATIVE_NR NR_syscalls +#define SECCOMP_ARCH_NATIVE_NAME "csky" + +#endif /* _ASM_SECCOMP_H */
Signature · 1 line
2.29.2
PATCH 2/8 parisc: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for parisc.
--- arch/parisc/include/asm/Kbuild | 1 - arch/parisc/include/asm/seccomp.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 arch/parisc/include/asm/seccomp.h
arch/parisc/include/asm/Kbuild +0 -1
@@ -5,5 +5,4 @@ generated-y += syscall_table_c32.h generic-y += kvm_para.h generic-y += local64.h generic-y += mcs_spinlock.h -generic-y += seccomp.h generic-y += user.h
arch/parisc/include/asm/seccomp.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_SECCOMP_H +#define _ASM_SECCOMP_H + +#include <asm-generic/seccomp.h> + +#ifdef CONFIG_64BIT +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PARISC64 +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "parisc64" +# ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT AUDIT_ARCH_PARISC +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "parisc" +# endif +#else /* !CONFIG_64BIT */ +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PARISC +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "parisc" +#endif + +#endif /* _ASM_SECCOMP_H */
Signature · 1 line
2.29.2
Re: [PATCH seccomp 2/8] parisc: Enable seccomp architecture tracking
Quoted 6 lines · YiFei Zhu
From: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for parisc.
Quoted 1 line
Signed-off-by YiFei Zhu <[email protected]>
I did compile- and boot-tested it, works on 32- and 64-bit parisc kernel. I don't know how to test it actually, but anyway:
Thanks!
Helge
Quoted 45 lines
--- arch/parisc/include/asm/Kbuild | 1 - arch/parisc/include/asm/seccomp.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 arch/parisc/include/asm/seccomp.harch/parisc/include/asm/Kbuild +0
-1@@ -5,5 +5,4 @@ generated-y += syscall_table_c32.h generic-y += kvm_para.h generic-y += local64.h generic-y += mcs_spinlock.h -generic-y += seccomp.h generic-y += user.harch/parisc/include/asm/seccomp.h new file +22
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_SECCOMP_H +#define _ASM_SECCOMP_H + +#include <asm-generic/seccomp.h> + +#ifdef CONFIG_64BIT +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PARISC64 +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "parisc64" +# ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT AUDIT_ARCH_PARISC +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "parisc" +# endif +#else /* !CONFIG_64BIT */ +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PARISC +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "parisc" +#endif + +#endif /* _ASM_SECCOMP_H */
PATCH 3/8 powerpc: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for powerpc.
--- arch/powerpc/include/asm/seccomp.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/powerpc/include/asm/seccomp.h +21 -0
@@ -8,4 +8,25 @@#include <asm-generic/seccomp.h> +#ifdef __LITTLE_ENDIAN__ +#define __SECCOMP_ARCH_LE_BIT __AUDIT_ARCH_LE +#else +#define __SECCOMP_ARCH_LE_BIT 0 +#endif + +#ifdef CONFIG_PPC64 +# define SECCOMP_ARCH_NATIVE (AUDIT_ARCH_PPC64 | __SECCOMP_ARCH_LE) +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "ppc64" +# ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT (AUDIT_ARCH_PPC | __SECCOMP_ARCH_LE) +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "powerpc" +# endif +#else /* !CONFIG_PPC64 */ +# define SECCOMP_ARCH_NATIVE (AUDIT_ARCH_PPC | __SECCOMP_ARCH_LE) +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "powerpc" +#endif +#endif /* _ASM_POWERPC_SECCOMP_H */
Signature · 1 line
2.29.2
Michael Ellerman
reviewerRe: [PATCH seccomp 3/8] powerpc: Enable seccomp architecture tracking
Quoted 16 lines · YiFei Zhu
From: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for powerpc.
Signed-off-by YiFei Zhu <[email protected]>--- arch/powerpc/include/asm/seccomp.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)arch/powerpc/include/asm/seccomp.h +0
-0
arch/powerpc/include/asm/seccomp.h line 11
Quoted 4 lines
arch/powerpc/include/asm/seccomp.h +1
-0@@ -8,4 +8,25 @@#include <asm-generic/seccomp.h> +#ifdef __LITTLE_ENDIAN__
As Kees mentioned this should (must?!) match the configured endian.
But I think it would still be better to use the CONFIG symbol, which is CONFIG_CPU_LITTLE_ENDIAN.
arch/powerpc/include/asm/seccomp.h line 18
Quoted 7 lines
arch/powerpc/include/asm/seccomp.h +7
-0+#define __SECCOMP_ARCH_LE_BIT __AUDIT_ARCH_LE +#else +#define __SECCOMP_ARCH_LE_BIT 0 +#endif + +#ifdef CONFIG_PPC64 +# define SECCOMP_ARCH_NATIVE (AUDIT_ARCH_PPC64 | __SECCOMP_ARCH_LE)
You use __SECCOMP_ARCH_LE there, but previously you only defined __SECCOMP_ARCH_LE_BIT.
Is there some magic somewhere that defines __SECCOMP_ARCH_LE based on __SECCOMP_ARCH_LE_BIT ?
arch/powerpc/include/asm/seccomp.h line 20
Quoted 2 lines
arch/powerpc/include/asm/seccomp.h +2
-0+# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "ppc64"
What's the name used for?
Usually we use "ppc64" for 64-bit big endian and "ppc64le" for 64-bit little endian.
arch/powerpc/include/asm/seccomp.h line 24
Quoted 4 lines
arch/powerpc/include/asm/seccomp.h +4
-0+# ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT (AUDIT_ARCH_PPC | __SECCOMP_ARCH_LE) +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "powerpc"
And usually we use "ppc" for 32-bit.
Quoted 10 lines
arch/powerpc/include/asm/seccomp.h +7
-0+# endif +#else /* !CONFIG_PPC64 */ +# define SECCOMP_ARCH_NATIVE (AUDIT_ARCH_PPC | __SECCOMP_ARCH_LE) +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "powerpc" +#endif +#endif /* _ASM_POWERPC_SECCOMP_H */ Signature · 1 line
2.29.2
cheers
Re: [PATCH seccomp 3/8] powerpc: Enable seccomp architecture tracking
Quoted 6 lines · Michael Ellerman
Quoted 1 line
+#ifdef
__LITTLE_ENDIAN__As Kees mentioned this should (must?!) match the configured endian.
But I think it would still be better to use the CONFIG symbol, which is
CONFIG_CPU_LITTLE_ENDIAN.
My attempt here is to be consistent with asm/syscall.h syscall_get_arch [1]. Would it make sense to change that to CONFIG_CPU_LITTLE_ENDIAN then?
[1] https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/asm/syscall.h#L116
Quoted 7 lines
Quoted 1 line
+# define
SECCOMP_ARCH_NATIVE(AUDIT_ARCH_PPC64|__SECCOMP_ARCH_LE)You use
__SECCOMP_ARCH_LEthere, but previously you only defined__SECCOMP_ARCH_LE_BIT.Is there some magic somewhere that defines
__SECCOMP_ARCH_LEbased on__SECCOMP_ARCH_LE_BIT?
Oops, my bad here.
Quoted 4 lines
arch/powerpc/include/asm/seccomp.h line 20
Quoted 2 lines
arch/powerpc/include/asm/seccomp.h +2
-0+# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "ppc64"What's the name used for?
This is used in the last patch in this series to report in procfs the name of each architecture tracked by the bitmap cache.
Quoted 4 lines
Usually we use "ppc64" for 64-bit big endian and "ppc64le" for 64-bit little endian.
And usually we use "ppc" for 32-bit.
Ok.
YiFei Zhu
Michael Ellerman
reviewerRe: [PATCH seccomp 3/8] powerpc: Enable seccomp architecture tracking
Quoted 5 lines · YiFei Zhu
Quoted 4 lines · Michael Ellerman
Quoted 1 line
+#ifdef
__LITTLE_ENDIAN__As Kees mentioned this should (must?!) match the configured endian.
Quoted 8 lines
Quoted 2 lines
But I think it would still be better to use the CONFIG symbol, which is
CONFIG_CPU_LITTLE_ENDIAN.My attempt here is to be consistent with
asm/syscall.hsyscall_get_arch[1]. Would it make sense to change that toCONFIG_CPU_LITTLE_ENDIANthen?[1] https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/asm/syscall.h#L116
Looking across the tree with have thousands of usages of __LITTLE_ENDIAN__, so it's probably not worth converting to CONFIG_CPU_LITTLE_ENDIAN.
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
+# define
SECCOMP_ARCH_NATIVE(AUDIT_ARCH_PPC64|__SECCOMP_ARCH_LE)You use
__SECCOMP_ARCH_LEthere, but previously you only defined__SECCOMP_ARCH_LE_BIT.Is there some magic somewhere that defines
__SECCOMP_ARCH_LEbased on__SECCOMP_ARCH_LE_BIT?Oops, my bad here.
OK :)
Quoted 7 lines
Quoted 4 lines
arch/powerpc/include/asm/seccomp.h line 20
Quoted 2 lines
arch/powerpc/include/asm/seccomp.h +2
-0+# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "ppc64"What's the name used for?
This is used in the last patch in this series to report in procfs the name of each architecture tracked by the bitmap cache.
OK, yeah I think it would be better if the matched the uname -m values.
Quoted 6 lines
Quoted 4 lines
Usually we use "ppc64" for 64-bit big endian and "ppc64le" for 64-bit little endian.
And usually we use "ppc" for 32-bit.
Ok.
cheers
PATCH 4/8 riscv: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for riscv.
--- arch/riscv/include/asm/seccomp.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/riscv/include/asm/seccomp.h +10 -0
@@ -7,4 +7,14 @@#include <asm-generic/seccomp.h> +#ifdef CONFIG_64BIT +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV64 +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "riscv64" +#else /* !CONFIG_64BIT */ +# define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV32 +# define SECCOMP_ARCH_NATIVE_NR NR_syscalls +# define SECCOMP_ARCH_NATIVE_NAME "riscv32" +#endif +#endif /* _ASM_SECCOMP_H */
Signature · 1 line
2.29.2
PATCH 5/8 s390: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for s390.
--- arch/s390/include/asm/seccomp.h | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/s390/include/asm/seccomp.h +9 -0
@@ -16,4 +16,13 @@#include <asm-generic/seccomp.h> +#define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390X +#define SECCOMP_ARCH_NATIVE_NR NR_syscalls +#define SECCOMP_ARCH_NATIVE_NAME "s390x" +#ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT AUDIT_ARCH_S390 +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "s390" +#endif +#endif /* _ASM_S390_SECCOMP_H */
Signature · 1 line
2.29.2
Re: [PATCH seccomp 5/8] s390: Enable seccomp architecture tracking
Quoted 18 lines · YiFei Zhu
From: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for s390.
Signed-off-by YiFei Zhu <[email protected]>--- arch/s390/include/asm/seccomp.h | 9 +++++++++ 1 file changed, 9 insertions(+)arch/s390/include/asm/seccomp.h +0
-0@@ -16,4 +16,13 @@#include <asm-generic/seccomp.h>
arch/s390/include/asm/seccomp.h line 27
Quoted 10 lines
arch/s390/include/asm/seccomp.h +9
-0+#define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390X +#define SECCOMP_ARCH_NATIVE_NR NR_syscalls +#define SECCOMP_ARCH_NATIVE_NAME "s390x" +#ifdef CONFIG_COMPAT +# define SECCOMP_ARCH_COMPAT AUDIT_ARCH_S390 +# define SECCOMP_ARCH_COMPAT_NR NR_syscalls +# define SECCOMP_ARCH_COMPAT_NAME "s390" +#endif +
PATCH 6/8 sh: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for sh.
--- arch/sh/include/asm/seccomp.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/sh/include/asm/seccomp.h +10 -0
@@ -8,4 +8,14 @@#define __NR_seccomp_exit __NR_exit#define __NR_seccomp_sigreturn __NR_rt_sigreturn +#ifdef CONFIG_CPU_LITTLE_ENDIAN +#define __SECCOMP_ARCH_LE_BIT __AUDIT_ARCH_LE +#else +#define __SECCOMP_ARCH_LE_BIT 0 +#endif + +#define SECCOMP_ARCH_NATIVE (AUDIT_ARCH_SH | __SECCOMP_ARCH_LE) +#define SECCOMP_ARCH_NATIVE_NR NR_syscalls +#define SECCOMP_ARCH_NATIVE_NAME "sh" +#endif /* __ASM_SECCOMP_H */
Signature · 1 line
2.29.2
PATCH 7/8 xtensa: Enable seccomp architecture tracking
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
To enable seccomp constant action bitmaps, we need to have a static mapping to the audit architecture and system call table size. Add these for xtensa.
--- arch/xtensa/include/asm/Kbuild | 1 - arch/xtensa/include/asm/seccomp.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 arch/xtensa/include/asm/seccomp.h
arch/xtensa/include/asm/Kbuild +0 -1
@@ -7,5 +7,4 @@ generic-y += mcs_spinlock.h generic-y += param.h generic-y += qrwlock.h generic-y += qspinlock.h -generic-y += seccomp.h generic-y += user.h
arch/xtensa/include/asm/seccomp.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_SECCOMP_H +#define _ASM_SECCOMP_H + +#include <asm-generic/seccomp.h> + +#define SECCOMP_ARCH_NATIVE AUDIT_ARCH_XTENSA +#define SECCOMP_ARCH_NATIVE_NR NR_syscalls +#define SECCOMP_ARCH_NATIVE_NAME "xtensa" + +#endif /* _ASM_SECCOMP_H */
Signature · 1 line
2.29.2
PATCH 8/8 seccomp/cache: Report cache data through /proc/pid/seccomp_cache
In reply to YiFei ZhuFrom: YiFei Zhu <[email protected]>
Currently the kernel does not provide an infrastructure to translate architecture numbers to a human-readable name. Translating syscall numbers to syscall names is possible through FTRACE_SYSCALL infrastructure but it does not provide support for compat syscalls.
This will create a file for each PID as /proc/pid/seccomp_cache. The file will be empty when no seccomp filters are loaded, or be in the format of:
<arch name> <decimal syscall number> <ALLOW | FILTER> where ALLOW means the cache is guaranteed to allow the syscall, and filter means the cache will pass the syscall to the BPF filter.
For the docker default profile on x86_64 it looks like:x86_64 0 ALLOWx86_64 1 ALLOWx86_64 2 ALLOWx86_64 3 ALLOW
[...]x86_64 132 ALLOWx86_64 133 ALLOWx86_64 134 FILTERx86_64 135 FILTERx86_64 136 FILTERx86_64 137 ALLOWx86_64 138 ALLOWx86_64 139 FILTERx86_64 140 ALLOWx86_64 141 ALLOW
[...]
This file is guarded by CONFIG_SECCOMP_CACHE_DEBUG with a default of N because I think certain users of seccomp might not want the application to know which syscalls are definitely usable. For the same reason, it is also guarded by CAP_SYS_ADMIN.
--- arch/Kconfig | 15 +++++++++++ fs/proc/base.c | 6 +++++ include/linux/seccomp.h | 7 +++++ kernel/seccomp.c | 59 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+)
arch/Kconfig +15 -0
@@ -514,6 +514,21 @@ config SECCOMP_FILTER See Documentation/userspace-api/seccomp_filter.rst for details. +config SECCOMP_CACHE_DEBUG + bool "Show seccomp filter cache status in /proc/pid/seccomp_cache" + depends on SECCOMP + depends on SECCOMP_FILTER && !HAVE_SPARSE_SYSCALL_NR + depends on PROC_FS + help + This enables the /proc/pid/seccomp_cache interface to monitor + seccomp cache data. The file format is subject to change. Reading + the file requires CAP_SYS_ADMIN. + + This option is for debugging only. Enabling presents the risk that + an adversary may be able to infer the seccomp filter logic. + + If unsure, say N. + config HAVE_ARCH_STACKLEAK bool help
fs/proc/base.c +6 -0
@@ -3261,6 +3261,9 @@ static const struct pid_entry tgid_base_stuff[] = {#ifdef CONFIG_PROC_PID_ARCH_STATUS ONE("arch_status", S_IRUGO, proc_pid_arch_status),#endif +#ifdef CONFIG_SECCOMP_CACHE_DEBUG + ONE("seccomp_cache", S_IRUSR, proc_pid_seccomp_cache), +#endif };static int proc_tgid_base_readdir (struct file *file,struct dir_context *ctx)
@@ -3590,6 +3593,9 @@ static const struct pid_entry tid_base_stuff[] = {#ifdef CONFIG_PROC_PID_ARCH_STATUS ONE("arch_status", S_IRUGO, proc_pid_arch_status),#endif +#ifdef CONFIG_SECCOMP_CACHE_DEBUG + ONE("seccomp_cache", S_IRUSR, proc_pid_seccomp_cache), +#endif };static int proc_tid_base_readdir (struct file *file,struct dir_context *ctx)
include/linux/seccomp.h +7 -0
@@ -121,4 +121,11 @@ static inline long seccomp_get_metadata(struct task_struct *task,return -EINVAL ; }#endif /* CONFIG_SECCOMP_FILTER && CONFIG_CHECKPOINT_RESTORE */ + +#ifdef CONFIG_SECCOMP_CACHE_DEBUG +struct seq_file ; + +int proc_pid_seccomp_cache (struct seq_file *m,struct pid_namespace *ns, +struct pid *pid,struct task_struct *task); +#endif #endif /* _LINUX_SECCOMP_H */
kernel/seccomp.c +59 -0
68 lines not on this page · raw message
Signature · 1 line
2.29.2
Quoted 10 lines · YiFei Zhu
From: YiFei Zhu <[email protected]>
This patch series enables bitmap cache for the remaining arches with
SECCOMP_FILTER, other than MIPS.I was unable to find any of the arches having subarch-specific
NR_syscallsmacros, so genericNR_syscallsis used. SH'ssyscall_get_archseems to only have the 32-bit subarch implementation. I'm not sure if this is expected.
Quoted 5 lines
This series has not been tested; I have not built all the cross compilers necessary to build test, let alone run the kernel or benchmark the performance, so help on making sure the bitmap cache works as expected would be appreciated. The series applies on top of Kees's for-next/seccomp branch.
Thank you! This looks good. I wonder if the different handling of little endian is worth solving -- I'm suspicious about powerpc's use of __LITTLE_ENDIAN__ vs a CONFIG, but I guess the compiler would match the target endian-ness. Regardless, it captures what the architectures are doing, and gets things standardized.
Quoted 4 lines
YiFei Zhu (8):
csky: Enable seccomp architecture tracking
parisc: Enable seccomp architecture tracking
I don't have compilers for these.
Quoted 3 lines
powerpc: Enable seccomp architecture tracking
riscv: Enable seccomp architecture tracking
s390: Enable seccomp architecture tracking
These I can build-test immediately.
Quoted 2 lines
sh: Enable seccomp architecture tracking
xtensa: Enable seccomp architecture tracking
These two are available in Ubuntu's cross compiler set, so I'll get them added to my cross-builders.
Quoted 1 line
seccomp/cache: Report cache data through
/proc/pid/seccomp_cache
In the meantime, I'll wait a bit to see if we can get some Acks/Reviews from arch maintainers. :)
-Kees
Quoted 24 lines
arch/Kconfig | 15 ++++++++ arch/csky/include/asm/Kbuild | 1 - arch/csky/include/asm/seccomp.h | 11 ++++++ arch/parisc/include/asm/Kbuild | 1 - arch/parisc/include/asm/seccomp.h | 22 +++++++++++ arch/powerpc/include/asm/seccomp.h | 21 +++++++++++ arch/riscv/include/asm/seccomp.h | 10 +++++ arch/s390/include/asm/seccomp.h | 9 +++++ arch/sh/include/asm/seccomp.h | 10 +++++ arch/xtensa/include/asm/Kbuild | 1 - arch/xtensa/include/asm/seccomp.h | 11 ++++++ fs/proc/base.c | 6 +++ include/linux/seccomp.h | 7 ++++ kernel/seccomp.c | 59 ++++++++++++++++++++++++++++++ 14 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 arch/csky/include/asm/seccomp.h create mode 100644 arch/parisc/include/asm/seccomp.h create mode 100644 arch/xtensa/include/asm/seccomp.hbase-commit:
38c37e8fd3d2590c4234d8cfbc22158362f0eb04--
2.29.2
Signature · 1 line
Kees Cook