diff options
| author | Stian Halseth <stian@itx.no> | 2026-09-02 09:27:44 +0200 |
|---|---|---|
| committer | Andreas Larsson <andreas@gaisler.com> | 2026-10-09 16:54:18 +0200 |
| commit | 60b5c9eda5a37449a8611bdd7c613f4aa827da00 (patch) | |
| tree | 550aa1f008ee137ba5117ff4387e2e7fc4507b8f /tools/lib/python | |
| parent | 9840f43c3d098fcb2d0ddc1b4ef79ef2bc008ec0 (diff) | |
| download | linux-next-60b5c9eda5a37449a8611bdd7c613f4aa827da00.tar.gz linux-next-60b5c9eda5a37449a8611bdd7c613f4aa827da00.zip | |
sparc64: add seccomp filter support
sparc is the last architecture besides alpha without SECCOMP_FILTER,
which systemd, docker, flatpak and the like all want, and userspace
support already exists as a pending libseccomp pull request.
Everything the filter mode needs is in fact already in place:
syscall_get_arch(), syscall_get_arguments() and
syscall_set_return_value() have long been provided for audit and
ptrace, TIF_SECCOMP is already in the syscall-entry work mask, and
strict-mode seccomp has been wired up for years. What is missing is
letting seccomp veto a syscall and honouring the return value it
sets.
Rework the entry hook accordingly: syscall_trace_enter() now runs the
ptrace entry report first and seccomp second (matching the generic
entry code, so a tracer's changes are seen by the filter), and
returns -1 when the syscall has been denied. On denial the return
value and the carry bit have already been set in pt_regs -
syscall_set_return_value() for a ptrace abort, the seccomp core for
SECCOMP_RET_ERRNO/TRAP/TRACE/KILL - so the assembler stubs must no
longer force -ENOSYS; they instead branch to a new linux_syscall_skip
path that advances TPC/TNPC past the trap instruction and returns
through the syscall exit work without storing a new return value.
The old behaviour of a ptrace entry abort (ENOSYS with the carry bit
set, followed by the exit report) is preserved, it is just set up in
C now.
syscall_rollback()'s XXX comment is replaced with an explanation of
why a no-op is correct: every caller runs before the syscall has been
invoked, and on sparc the first argument register is only overwritten
by the return value once the syscall has actually run.
SECCOMP_ARCH_NATIVE/COMPAT are defined so the constant-action bitmap
cache works for both 64-bit and compat 32-bit tasks.
Filter support is 64-bit only for now, as strict mode already was:
the 32-bit kernel's entry path has no equivalent plumbing.
Tested on an UltraSPARC T4-1: the seccomp_bpf selftest passes 95 of
95 (16 skipped for missing optional features such as uprobes), the
libseccomp test suite with its pending SPARC support passes 5190 of
5190 including the live tests, and docker containers run confined by
both the default and custom seccomp profiles.
Link: https://github.com/sparclinux/issues/issues/11
Signed-off-by: Stian Halseth <stian@itx.no>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Link: https://lore.kernel.org/r/20260902072745.3412940-2-stian@itx.no
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
