Skip to content

Commit 282a181

Browse files
zhuyifei1999kees
authored andcommitted
seccomp: Move config option SECCOMP to arch/Kconfig
In order to make adding configurable features into seccomp easier, it's better to have the options at one single location, considering especially that the bulk of seccomp code is arch-independent. An quick look also show that many SECCOMP descriptions are outdated; they talk about /proc rather than prctl. As a result of moving the config option and keeping it default on, architectures arm, arm64, csky, riscv, sh, and xtensa did not have SECCOMP on by default prior to this and SECCOMP will be default in this change. Architectures microblaze, mips, powerpc, s390, sh, and sparc have an outdated depend on PROC_FS and this dependency is removed in this change. Suggested-by: Jann Horn <[email protected]> Link: https://lore.kernel.org/lkml/CAG48ez1YWz9cnp08UZgeieYRhHdqh-ch7aNwc4JRBnGyrmgfMg@mail.gmail.com/ Signed-off-by: YiFei Zhu <[email protected]> [kees: added HAVE_ARCH_SECCOMP help text, tweaked wording] Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/9ede6ef35c847e58d61e476c6a39540520066613.1600951211.git.yifeifz2@illinois.edu
1 parent e953aea commit 282a181

File tree

15 files changed

+33
-216
lines changed

15 files changed

+33
-216
lines changed

arch/Kconfig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,23 @@ config ARCH_WANT_OLD_COMPAT_IPC
444444
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
445445
bool
446446

447+
config HAVE_ARCH_SECCOMP
448+
bool
449+
help
450+
An arch should select this symbol to support seccomp mode 1 (the fixed
451+
syscall policy), and must provide an overrides for __NR_seccomp_sigreturn,
452+
and compat syscalls if the asm-generic/seccomp.h defaults need adjustment:
453+
- __NR_seccomp_read_32
454+
- __NR_seccomp_write_32
455+
- __NR_seccomp_exit_32
456+
- __NR_seccomp_sigreturn_32
457+
447458
config HAVE_ARCH_SECCOMP_FILTER
448459
bool
460+
select HAVE_ARCH_SECCOMP
449461
help
450462
An arch should select this symbol if it provides all of these things:
463+
- all the requirements for HAVE_ARCH_SECCOMP
451464
- syscall_get_arch()
452465
- syscall_get_arguments()
453466
- syscall_rollback()
@@ -458,6 +471,23 @@ config HAVE_ARCH_SECCOMP_FILTER
458471
results in the system call being skipped immediately.
459472
- seccomp syscall wired up
460473

474+
config SECCOMP
475+
prompt "Enable seccomp to safely execute untrusted bytecode"
476+
def_bool y
477+
depends on HAVE_ARCH_SECCOMP
478+
help
479+
This kernel feature is useful for number crunching applications
480+
that may need to handle untrusted bytecode during their
481+
execution. By using pipes or other transports made available
482+
to the process as file descriptors supporting the read/write
483+
syscalls, it's possible to isolate those applications in their
484+
own address space using seccomp. Once seccomp is enabled via
485+
prctl(PR_SET_SECCOMP) or the seccomp() syscall, it cannot be
486+
disabled and the task is only allowed to execute a few safe
487+
syscalls defined by each seccomp mode.
488+
489+
If unsure, say Y.
490+
461491
config SECCOMP_FILTER
462492
def_bool y
463493
depends on HAVE_ARCH_SECCOMP_FILTER && SECCOMP && NET

arch/arm/Kconfig

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ config ARM
6767
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
6868
select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
6969
select HAVE_ARCH_MMAP_RND_BITS if MMU
70+
select HAVE_ARCH_SECCOMP
7071
select HAVE_ARCH_SECCOMP_FILTER if AEABI && !OABI_COMPAT
7172
select HAVE_ARCH_THREAD_STRUCT_WHITELIST
7273
select HAVE_ARCH_TRACEHOOK
@@ -1617,20 +1618,6 @@ config UACCESS_WITH_MEMCPY
16171618
However, if the CPU data cache is using a write-allocate mode,
16181619
this option is unlikely to provide any performance gain.
16191620

1620-
config SECCOMP
1621-
bool
1622-
prompt "Enable seccomp to safely compute untrusted bytecode"
1623-
help
1624-
This kernel feature is useful for number crunching applications
1625-
that may need to compute untrusted bytecode during their
1626-
execution. By using pipes or other transports made available to
1627-
the process as file descriptors supporting the read/write
1628-
syscalls, it's possible to isolate those applications in
1629-
their own address space using seccomp. Once seccomp is
1630-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1631-
and the task is only allowed to execute a few safe syscalls
1632-
defined by each seccomp mode.
1633-
16341621
config PARAVIRT
16351622
bool "Enable paravirtualization code"
16361623
help

arch/arm64/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,19 +1033,6 @@ config ARCH_ENABLE_SPLIT_PMD_PTLOCK
10331033
config CC_HAVE_SHADOW_CALL_STACK
10341034
def_bool $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18)
10351035

1036-
config SECCOMP
1037-
bool "Enable seccomp to safely compute untrusted bytecode"
1038-
help
1039-
This kernel feature is useful for number crunching applications
1040-
that may need to compute untrusted bytecode during their
1041-
execution. By using pipes or other transports made available to
1042-
the process as file descriptors supporting the read/write
1043-
syscalls, it's possible to isolate those applications in
1044-
their own address space using seccomp. Once seccomp is
1045-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1046-
and the task is only allowed to execute a few safe syscalls
1047-
defined by each seccomp mode.
1048-
10491036
config PARAVIRT
10501037
bool "Enable paravirtualization code"
10511038
help

arch/csky/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,3 @@ endmenu
309309
source "arch/csky/Kconfig.platforms"
310310

311311
source "kernel/Kconfig.hz"
312-
313-
config SECCOMP
314-
bool "Enable seccomp to safely compute untrusted bytecode"
315-
help
316-
This kernel feature is useful for number crunching applications
317-
that may need to compute untrusted bytecode during their
318-
execution. By using pipes or other transports made available to
319-
the process as file descriptors supporting the read/write
320-
syscalls, it's possible to isolate those applications in
321-
their own address space using seccomp. Once seccomp is
322-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
323-
and the task is only allowed to execute a few safe syscalls
324-
defined by each seccomp mode.

arch/microblaze/Kconfig

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ config MICROBLAZE
2626
select GENERIC_SCHED_CLOCK
2727
select HAVE_ARCH_HASH
2828
select HAVE_ARCH_KGDB
29+
select HAVE_ARCH_SECCOMP
2930
select HAVE_DEBUG_KMEMLEAK
3031
select HAVE_DMA_CONTIGUOUS
3132
select HAVE_DYNAMIC_FTRACE
@@ -120,23 +121,6 @@ config CMDLINE_FORCE
120121
Set this to have arguments from the default kernel command string
121122
override those passed by the boot loader.
122123

123-
config SECCOMP
124-
bool "Enable seccomp to safely compute untrusted bytecode"
125-
depends on PROC_FS
126-
default y
127-
help
128-
This kernel feature is useful for number crunching applications
129-
that may need to compute untrusted bytecode during their
130-
execution. By using pipes or other transports made available to
131-
the process as file descriptors supporting the read/write
132-
syscalls, it's possible to isolate those applications in
133-
their own address space using seccomp. Once seccomp is
134-
enabled via /proc/<pid>/seccomp, it cannot be disabled
135-
and the task is only allowed to execute a few safe syscalls
136-
defined by each seccomp mode.
137-
138-
If unsure, say Y. Only embedded should say N here.
139-
140124
endmenu
141125

142126
menu "Kernel features"

arch/mips/Kconfig

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,23 +3004,6 @@ config PHYSICAL_START
30043004
specified in the "crashkernel=YM@XM" command line boot parameter
30053005
passed to the panic-ed kernel).
30063006

3007-
config SECCOMP
3008-
bool "Enable seccomp to safely compute untrusted bytecode"
3009-
depends on PROC_FS
3010-
default y
3011-
help
3012-
This kernel feature is useful for number crunching applications
3013-
that may need to compute untrusted bytecode during their
3014-
execution. By using pipes or other transports made available to
3015-
the process as file descriptors supporting the read/write
3016-
syscalls, it's possible to isolate those applications in
3017-
their own address space using seccomp. Once seccomp is
3018-
enabled via /proc/<pid>/seccomp, it cannot be disabled
3019-
and the task is only allowed to execute a few safe syscalls
3020-
defined by each seccomp mode.
3021-
3022-
If unsure, say Y. Only embedded should say N here.
3023-
30243007
config MIPS_O32_FP64_SUPPORT
30253008
bool "Support for O32 binaries using 64-bit FP" if !CPU_MIPSR6
30263009
depends on 32BIT || MIPS32_O32

arch/parisc/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,3 @@ endmenu
378378

379379

380380
source "drivers/parisc/Kconfig"
381-
382-
config SECCOMP
383-
def_bool y
384-
prompt "Enable seccomp to safely compute untrusted bytecode"
385-
help
386-
This kernel feature is useful for number crunching applications
387-
that may need to compute untrusted bytecode during their
388-
execution. By using pipes or other transports made available to
389-
the process as file descriptors supporting the read/write
390-
syscalls, it's possible to isolate those applications in
391-
their own address space using seccomp. Once seccomp is
392-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
393-
and the task is only allowed to execute a few safe syscalls
394-
defined by each seccomp mode.
395-
396-
If unsure, say Y. Only embedded should say N here.

arch/powerpc/Kconfig

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -934,23 +934,6 @@ config ARCH_WANTS_FREEZER_CONTROL
934934

935935
source "kernel/power/Kconfig"
936936

937-
config SECCOMP
938-
bool "Enable seccomp to safely compute untrusted bytecode"
939-
depends on PROC_FS
940-
default y
941-
help
942-
This kernel feature is useful for number crunching applications
943-
that may need to compute untrusted bytecode during their
944-
execution. By using pipes or other transports made available to
945-
the process as file descriptors supporting the read/write
946-
syscalls, it's possible to isolate those applications in
947-
their own address space using seccomp. Once seccomp is
948-
enabled via /proc/<pid>/seccomp, it cannot be disabled
949-
and the task is only allowed to execute a few safe syscalls
950-
defined by each seccomp mode.
951-
952-
If unsure, say Y. Only embedded should say N here.
953-
954937
config PPC_MEM_KEYS
955938
prompt "PowerPC Memory Protection Keys"
956939
def_bool y

arch/riscv/Kconfig

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,6 @@ menu "Kernel features"
333333

334334
source "kernel/Kconfig.hz"
335335

336-
config SECCOMP
337-
bool "Enable seccomp to safely compute untrusted bytecode"
338-
help
339-
This kernel feature is useful for number crunching applications
340-
that may need to compute untrusted bytecode during their
341-
execution. By using pipes or other transports made available to
342-
the process as file descriptors supporting the read/write
343-
syscalls, it's possible to isolate those applications in
344-
their own address space using seccomp. Once seccomp is
345-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
346-
and the task is only allowed to execute a few safe syscalls
347-
defined by each seccomp mode.
348-
349336
config RISCV_SBI_V01
350337
bool "SBI v0.1 support"
351338
default y

arch/s390/Kconfig

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -791,23 +791,6 @@ config CRASH_DUMP
791791

792792
endmenu
793793

794-
config SECCOMP
795-
def_bool y
796-
prompt "Enable seccomp to safely compute untrusted bytecode"
797-
depends on PROC_FS
798-
help
799-
This kernel feature is useful for number crunching applications
800-
that may need to compute untrusted bytecode during their
801-
execution. By using pipes or other transports made available to
802-
the process as file descriptors supporting the read/write
803-
syscalls, it's possible to isolate those applications in
804-
their own address space using seccomp. Once seccomp is
805-
enabled via /proc/<pid>/seccomp, it cannot be disabled
806-
and the task is only allowed to execute a few safe syscalls
807-
defined by each seccomp mode.
808-
809-
If unsure, say Y.
810-
811794
config CCW
812795
def_bool y
813796

arch/sh/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -600,22 +600,6 @@ config PHYSICAL_START
600600
where the fail safe kernel needs to run at a different address
601601
than the panic-ed kernel.
602602

603-
config SECCOMP
604-
bool "Enable seccomp to safely compute untrusted bytecode"
605-
depends on PROC_FS
606-
help
607-
This kernel feature is useful for number crunching applications
608-
that may need to compute untrusted bytecode during their
609-
execution. By using pipes or other transports made available to
610-
the process as file descriptors supporting the read/write
611-
syscalls, it's possible to isolate those applications in
612-
their own address space using seccomp. Once seccomp is
613-
enabled via prctl, it cannot be disabled and the task is only
614-
allowed to execute a few safe syscalls defined by each seccomp
615-
mode.
616-
617-
If unsure, say N.
618-
619603
config SMP
620604
bool "Symmetric multi-processing support"
621605
depends on SYS_SUPPORTS_SMP

arch/sparc/Kconfig

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ config SPARC
2323
select HAVE_OPROFILE
2424
select HAVE_ARCH_KGDB if !SMP || SPARC64
2525
select HAVE_ARCH_TRACEHOOK
26+
select HAVE_ARCH_SECCOMP if SPARC64
2627
select HAVE_EXIT_THREAD
2728
select HAVE_PCI
2829
select SYSCTL_EXCEPTION_TRACE
@@ -226,23 +227,6 @@ config EARLYFB
226227
help
227228
Say Y here to enable a faster early framebuffer boot console.
228229

229-
config SECCOMP
230-
bool "Enable seccomp to safely compute untrusted bytecode"
231-
depends on SPARC64 && PROC_FS
232-
default y
233-
help
234-
This kernel feature is useful for number crunching applications
235-
that may need to compute untrusted bytecode during their
236-
execution. By using pipes or other transports made available to
237-
the process as file descriptors supporting the read/write
238-
syscalls, it's possible to isolate those applications in
239-
their own address space using seccomp. Once seccomp is
240-
enabled via /proc/<pid>/seccomp, it cannot be disabled
241-
and the task is only allowed to execute a few safe syscalls
242-
defined by each seccomp mode.
243-
244-
If unsure, say Y. Only embedded should say N here.
245-
246230
config HOTPLUG_CPU
247231
bool "Support for hot-pluggable CPUs"
248232
depends on SPARC64 && SMP

arch/um/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,6 @@ config PGTABLE_LEVELS
173173
default 3 if 3_LEVEL_PGTABLES
174174
default 2
175175

176-
config SECCOMP
177-
def_bool y
178-
prompt "Enable seccomp to safely compute untrusted bytecode"
179-
help
180-
This kernel feature is useful for number crunching applications
181-
that may need to compute untrusted bytecode during their
182-
execution. By using pipes or other transports made available to
183-
the process as file descriptors supporting the read/write
184-
syscalls, it's possible to isolate those applications in
185-
their own address space using seccomp. Once seccomp is
186-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
187-
and the task is only allowed to execute a few safe syscalls
188-
defined by each seccomp mode.
189-
190-
If unsure, say Y.
191-
192176
config UML_TIME_TRAVEL_SUPPORT
193177
bool
194178
prompt "Support time-travel mode (e.g. for test execution)"

arch/x86/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,22 +1968,6 @@ config EFI_MIXED
19681968

19691969
If unsure, say N.
19701970

1971-
config SECCOMP
1972-
def_bool y
1973-
prompt "Enable seccomp to safely compute untrusted bytecode"
1974-
help
1975-
This kernel feature is useful for number crunching applications
1976-
that may need to compute untrusted bytecode during their
1977-
execution. By using pipes or other transports made available to
1978-
the process as file descriptors supporting the read/write
1979-
syscalls, it's possible to isolate those applications in
1980-
their own address space using seccomp. Once seccomp is
1981-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1982-
and the task is only allowed to execute a few safe syscalls
1983-
defined by each seccomp mode.
1984-
1985-
If unsure, say Y. Only embedded should say N here.
1986-
19871971
source "kernel/Kconfig.hz"
19881972

19891973
config KEXEC

arch/xtensa/Kconfig

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,6 @@ config HOTPLUG_CPU
217217

218218
Say N if you want to disable CPU hotplug.
219219

220-
config SECCOMP
221-
bool
222-
prompt "Enable seccomp to safely compute untrusted bytecode"
223-
help
224-
This kernel feature is useful for number crunching applications
225-
that may need to compute untrusted bytecode during their
226-
execution. By using pipes or other transports made available to
227-
the process as file descriptors supporting the read/write
228-
syscalls, it's possible to isolate those applications in
229-
their own address space using seccomp. Once seccomp is
230-
enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
231-
and the task is only allowed to execute a few safe syscalls
232-
defined by each seccomp mode.
233-
234220
config FAST_SYSCALL_XTENSA
235221
bool "Enable fast atomic syscalls"
236222
default n

0 commit comments

Comments
 (0)