mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] sparc32: add seccomp filter support
@ 2026-10-14  8:07 Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 1/3] sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}() Ludwig Rydberg
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ludwig Rydberg @ 2026-10-14  8:07 UTC (permalink / raw)
  To: Andreas Larsson, David S. Miller, Kees Cook, sparclinux
  Cc: Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz,
	Stian Halseth, Ludwig Rydberg

This adds SECCOMP_FILTER support for sparc32 on top of Stian Halseth's
sparc64 series (v2):
https://lore.kernel.org/r/20260902072745.3412940-1-stian@itx.no

Patch 1 splits syscall_trace() into syscall_trace_enter() and
syscall_trace_leave() as on sparc64 and most other architectures.

Patch 2 adds a call to seccomp_permit_syscall() in syscall_trace_enter()
to filter system calls. A denied syscall skips the call and goes
through the syscall exit work with the return value already set.

Patch 3 extends the seccomp_bpf selftest's SPARC support to sparc32.

Testing:
seccomp_bpf on v7.3-rc1 with the whole seccomp series applied on a
GR-CPCI-GR740 board from Frontgrade Gaisler:

- UP: pass:99 fail:0 skip:12
- SMP with out-of-tree patches that implement the futex atomic
  operations with CASA on LEON: pass:99 fail:0 skip:12
- SMP without them: pass:89 fail:10 skip:12.
  FUTEX depends on !(SPARC32 && SMP) (see 3f2bedabb62c) and glibc aborts
  with "The futex facility returned an unexpected error code" in the 10
  tests that use threads (KILL_thread,
  user_notification_filter_empty_threaded, tsync_vs_dead_thread_leader and
  the 7 TSYNC tests).

The 12 skipped tests need the UPROBES which sparc32 does not have.

Ludwig Rydberg (3):
  sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}()
  sparc32: add seccomp filter support
  selftests/seccomp: add sparc32 support

 arch/sparc/Kconfig                            |  2 +-
 arch/sparc/include/asm/thread_info_32.h       |  2 +
 arch/sparc/kernel/entry.S                     | 33 ++++++++--------
 arch/sparc/kernel/kernel.h                    |  3 +-
 arch/sparc/kernel/ptrace_32.c                 | 26 ++++++++-----
 tools/testing/selftests/seccomp/seccomp_bpf.c | 38 +++++++++++++------
 6 files changed, 66 insertions(+), 38 deletions(-)


base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
prerequisite-patch-id: 5772aba3cb572833df13529ec6bb03ae9e848e25
prerequisite-patch-id: 70a54ba398c763e45f9332ff4cc06b3f2a3e7825
--
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}()
  2026-10-14  8:07 [PATCH 0/3] sparc32: add seccomp filter support Ludwig Rydberg
@ 2026-10-14  8:07 ` Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 2/3] sparc32: add seccomp filter support Ludwig Rydberg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Ludwig Rydberg @ 2026-10-14  8:07 UTC (permalink / raw)
  To: Andreas Larsson, David S. Miller, Kees Cook, sparclinux
  Cc: Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz,
	Stian Halseth, Ludwig Rydberg

Drop the common syscall_trace() function and follow the pattern
that many other archs (including SPARC64) by having two explicit
functions called syscall_trace_{enter|leave}() instead.

Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
---
 arch/sparc/kernel/entry.S     | 21 +++++++++------------
 arch/sparc/kernel/kernel.h    |  3 ++-
 arch/sparc/kernel/ptrace_32.c | 19 ++++++++++---------
 3 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index ea51ef52c952..7218208e0a65 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -825,8 +825,8 @@ sys_sigreturn:
 	be	1f
 	 nop
 
-	call	syscall_trace
-	 mov	1, %o1
+	call	syscall_trace_leave
+	 nop
 
 1:
 	/* We don't want to muck with user registers like a
@@ -845,9 +845,8 @@ sys_rt_sigreturn:
 	be	1f
 	 nop
 
-	add	%sp, STACKFRAME_SZ, %o0
-	call	syscall_trace
-	 mov	1, %o1
+	call	syscall_trace_leave
+	 add	%sp, STACKFRAME_SZ, %o0
 
 1:
 	/* We are returning to a signal handler. */
@@ -929,9 +928,8 @@ linux_sparc_ni_syscall:
 	 or     %l7, %lo(sys_ni_syscall), %l7
 
 linux_syscall_trace:
-	add	%sp, STACKFRAME_SZ, %o0
-	call	syscall_trace
-	 mov	0, %o1
+	call	syscall_trace_enter
+	 add	%sp, STACKFRAME_SZ, %o0
 	cmp	%o0, 0
 	bne	3f
 	 mov	-ENOSYS, %o0
@@ -1050,10 +1048,9 @@ ret_sys_call:
 	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
 linux_syscall_trace2:
-	add	%sp, STACKFRAME_SZ, %o0
-	mov	1, %o1
-	call	syscall_trace
-	 add	%l1, 0x4, %l2			/* npc = npc+4 */
+	call	syscall_trace_leave
+	 add	%sp, STACKFRAME_SZ, %o0
+	add	%l1, 0x4, %l2			/* npc = npc+4 */
 	st	%l1, [%sp + STACKFRAME_SZ + PT_PC]
 	b	ret_trap_entry
 	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 4ee85051521a..e215157d5120 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -172,7 +172,8 @@ asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
                                unsigned long sp);
 
 /* ptrace_32.c */
-asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p);
+asmlinkage int syscall_trace_enter(struct pt_regs *regs);
+asmlinkage void syscall_trace_leave(struct pt_regs *regs);
 
 /* unaligned_32.c */
 asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn);
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index 5991b1731fee..3cd3a31ce677 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -433,16 +433,17 @@ long arch_ptrace(struct task_struct *child, long request,
 	return ret;
 }
 
-asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
+asmlinkage int syscall_trace_enter(struct pt_regs *regs)
 {
-	int ret = 0;
+	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
+	    !ptrace_report_syscall_permit_entry(regs))
+		return 1;
 
-	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
-		if (syscall_exit_p)
-			ptrace_report_syscall_exit(regs, 0);
-		else
-			ret = !ptrace_report_syscall_permit_entry(regs);
-	}
+	return 0;
+}
 
-	return ret;
+asmlinkage void syscall_trace_leave(struct pt_regs *regs)
+{
+	if (test_thread_flag(TIF_SYSCALL_TRACE))
+		ptrace_report_syscall_exit(regs, 0);
 }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] sparc32: add seccomp filter support
  2026-10-14  8:07 [PATCH 0/3] sparc32: add seccomp filter support Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 1/3] sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}() Ludwig Rydberg
@ 2026-10-14  8:07 ` Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 3/3] selftests/seccomp: add sparc32 support Ludwig Rydberg
  2026-10-14 16:36 ` [PATCH 0/3] sparc32: add seccomp filter support Magnus Lindholm
  3 siblings, 0 replies; 7+ messages in thread
From: Ludwig Rydberg @ 2026-10-14  8:07 UTC (permalink / raw)
  To: Andreas Larsson, David S. Miller, Kees Cook, sparclinux
  Cc: Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz,
	Stian Halseth, Ludwig Rydberg

Add handling of seccomp_permit_syscall() in syscall_trace_enter() to filter
system calls. Make the syscall_trace_enter() return -1 (skipped syscall)
and adapt callers to the new return value convention.

Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
---
 arch/sparc/Kconfig                      |  2 +-
 arch/sparc/include/asm/thread_info_32.h |  2 ++
 arch/sparc/kernel/entry.S               | 12 ++++++++----
 arch/sparc/kernel/ptrace_32.c           | 11 +++++++++--
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 8dd15256edf6..56d5ac7b228a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -23,7 +23,7 @@ config SPARC
 	select HAVE_ASM_MODVERSIONS
 	select HAVE_ARCH_KGDB if !SMP || SPARC64
 	select HAVE_ARCH_TRACEHOOK
-	select HAVE_ARCH_SECCOMP_FILTER if SPARC64
+	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_EXIT_THREAD
 	select HAVE_PCI
 	select SYSCTL_EXCEPTION_TRACE
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index fdaf7b171e0a..b51b080f1810 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -110,6 +110,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
 					 * TIF_NEED_RESCHED */
 #define TIF_MEMDIE		10	/* is terminating due to OOM killer */
+#define TIF_SECCOMP		11	/* secure computing */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -119,6 +120,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
 #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
 #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
+#define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 
 #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
 					 _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 7218208e0a65..db732395c048 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -930,9 +930,9 @@ linux_sparc_ni_syscall:
 linux_syscall_trace:
 	call	syscall_trace_enter
 	 add	%sp, STACKFRAME_SZ, %o0
-	cmp	%o0, 0
-	bne	3f
-	 mov	-ENOSYS, %o0
+	cmp	%o0, -1
+	be	linux_syscall_trace_exit
+	 nop
 
 	/* Syscall tracing can modify the registers.  */
 	ld	[%sp + STACKFRAME_SZ + PT_G1], %g1
@@ -1004,7 +1004,7 @@ do_syscall:
 
 	ld	[%curptr + TI_FLAGS], %l5
 	mov	%i3, %o3
-	andcc	%l5, _TIF_SYSCALL_TRACE, %g0
+	andcc	%l5, _TIF_SYSCALL_TRACE | _TIF_SECCOMP, %g0
 	mov	%i4, %o4
 	bne	linux_syscall_trace
 	 mov	%i0, %l6
@@ -1047,6 +1047,10 @@ ret_sys_call:
 	b	ret_trap_entry
 	 st	%l2, [%sp + STACKFRAME_SZ + PT_NPC]
 
+linux_syscall_trace_exit:
+	/* The syscall was skipped - exit tracing */
+	ld	[%sp + STACKFRAME_SZ + PT_NPC], %l1
+
 linux_syscall_trace2:
 	call	syscall_trace_leave
 	 add	%sp, STACKFRAME_SZ, %o0
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index 3cd3a31ce677..25d10c1b075f 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -24,6 +24,7 @@
 
 #include <linux/uaccess.h>
 #include <asm/cacheflush.h>
+#include <asm/syscall.h>
 
 #include "kernel.h"
 
@@ -436,8 +437,14 @@ long arch_ptrace(struct task_struct *child, long request,
 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    !ptrace_report_syscall_permit_entry(regs))
-		return 1;
+	    !ptrace_report_syscall_permit_entry(regs)) {
+		syscall_set_return_value(current, regs, -ENOSYS, 0);
+		return -1;
+	}
+
+	/* Do seccomp after ptrace; syscall may have changed. */
+	if (!seccomp_permit_syscall())
+		return -1;
 
 	return 0;
 }
-- 
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] selftests/seccomp: add sparc32 support
  2026-10-14  8:07 [PATCH 0/3] sparc32: add seccomp filter support Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 1/3] sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}() Ludwig Rydberg
  2026-10-14  8:07 ` [PATCH 2/3] sparc32: add seccomp filter support Ludwig Rydberg
@ 2026-10-14  8:07 ` Ludwig Rydberg
  2026-10-14  9:29   ` Stian Halseth
  2026-10-14 16:40   ` Kees Cook
  2026-10-14 16:36 ` [PATCH 0/3] sparc32: add seccomp filter support Magnus Lindholm
  3 siblings, 2 replies; 7+ messages in thread
From: Ludwig Rydberg @ 2026-10-14  8:07 UTC (permalink / raw)
  To: Andreas Larsson, David S. Miller, Kees Cook, sparclinux
  Cc: Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz,
	Stian Halseth, Ludwig Rydberg

Add SPARC32 definitions to seccomp_bpf selftest.

Reuse the sparc64 register handling on sparc32 but adapt the carry
bit handling to use %tstate on sparc64 and %psr on sparc32.

Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 38 +++++++++++++------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 3711060c22a7..60ae1de8201d 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1872,10 +1872,21 @@ TEST_F(TRACE_poke, getpid_runs_normally)
 # define ARCH_REGS		struct user_regs_struct
 # define SYSCALL_NUM(_regs)	(_regs).orig_d0
 # define SYSCALL_RET(_regs)	(_regs).d0
-#elif defined(__sparc__) && defined(__arch64__)
+#elif defined(__sparc__)
 # include <asm/ptrace.h>
+
+# if defined(__arch64__)
+#  include <asm/pstate.h>
+#  define CARRY_MASK			(TSTATE_ICARRY | TSTATE_XCARRY)
+#  define SPARC_CARRY_REG(_regs)	((_regs).tstate)
+# else
+#  include <asm/psr.h>
+#  define CARRY_MASK			PSR_C
+#  define SPARC_CARRY_REG(_regs)	((_regs).psr)
+# endif
+
 /*
- * PTRACE_GETREGS64/PTRACE_SETREGS64 transfer the uapi struct pt_regs,
+ * PTRACE_GETREGS{64}/PTRACE_SETREGS{64} transfer the uapi struct pt_regs,
  * but in the historical layout that omits %g0: the blob starts at %g1,
  * so every u_regs index is one lower than the register number suggests.
  */
@@ -1883,20 +1894,20 @@ TEST_F(TRACE_poke, getpid_runs_normally)
 # define SYSCALL_NUM(_regs)	(_regs).u_regs[0]	/* %g1 */
 # define SYSCALL_RET(_regs)	(_regs).u_regs[7]	/* %o0 */
 /*
- * A syscall error is signaled by the carry bit in tstate, with the
- * errno held in %o0 as a positive value; the carry can only be
- * written reliably once the syscall has been skipped or has run.
+ * A syscall error is signaled by the carry bit in tstate (SPARC64) or
+ * psr (SPARC32), with the errno held in %o0 as a positive value;
+ * the carry can only be written reliably once the syscall has been
+ * skipped or has run.
  */
-# define SPARC64_TSTATE_CARRY	0x0000001100000000UL	/* xcc.c | icc.c */
 # define SYSCALL_RET_SET(_regs, _val)				\
 	do {							\
 		typeof(_val) _result = (_val);			\
 		if (_result < 0) {				\
 			SYSCALL_RET(_regs) = -_result;		\
-			(_regs).tstate |= SPARC64_TSTATE_CARRY;	\
+			SPARC_CARRY_REG(_regs) |= CARRY_MASK;	\
 		} else {					\
 			SYSCALL_RET(_regs) = _result;		\
-			(_regs).tstate &= ~SPARC64_TSTATE_CARRY; \
+			SPARC_CARRY_REG(_regs) &= ~CARRY_MASK;	\
 		}						\
 	} while (0)
 # define SYSCALL_RET_SET_ON_PTRACE_EXIT
@@ -1967,14 +1978,19 @@ const bool ptrace_entry_set_syscall_ret =
 #if defined(__x86_64__) || defined(__i386__) || defined(__mips__) || defined(__mc68000__)
 # define ARCH_GETREGS(_regs)	ptrace(PTRACE_GETREGS, tracee, 0, &(_regs))
 # define ARCH_SETREGS(_regs)	ptrace(PTRACE_SETREGS, tracee, 0, &(_regs))
-#elif defined(__sparc__) && defined(__arch64__)
+#elif defined(__sparc__)
+# if defined(__arch64__)
 /*
  * The NT_PRSTATUS regset appends the register window, which struct
  * pt_regs does not carry; the sparc-specific requests transfer
  * struct pt_regs directly (and take the buffer in addr).
  */
-# define ARCH_GETREGS(_regs)	ptrace(PTRACE_GETREGS64, tracee, &(_regs), 0)
-# define ARCH_SETREGS(_regs)	ptrace(PTRACE_SETREGS64, tracee, &(_regs), 0)
+#  define ARCH_GETREGS(_regs)	ptrace(PTRACE_GETREGS64, tracee, &(_regs), 0)
+#  define ARCH_SETREGS(_regs)	ptrace(PTRACE_SETREGS64, tracee, &(_regs), 0)
+# else
+#  define ARCH_GETREGS(_regs)	ptrace(PTRACE_GETREGS, tracee, &(_regs), 0)
+#  define ARCH_SETREGS(_regs)	ptrace(PTRACE_SETREGS, tracee, &(_regs), 0)
+# endif
 #else
 # define ARCH_GETREGS(_regs)	({					\
 		struct iovec __v;					\
-- 
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] selftests/seccomp: add sparc32 support
  2026-10-14  8:07 ` [PATCH 3/3] selftests/seccomp: add sparc32 support Ludwig Rydberg
@ 2026-10-14  9:29   ` Stian Halseth
  2026-10-14 16:40   ` Kees Cook
  1 sibling, 0 replies; 7+ messages in thread
From: Stian Halseth @ 2026-10-14  9:29 UTC (permalink / raw)
  To: Ludwig Rydberg, Andreas Larsson, David S. Miller, Kees Cook, sparclinux
  Cc: Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

On Wed, 2026-10-14 at 10:07 +0200, Ludwig Rydberg wrote:
> Add SPARC32 definitions to seccomp_bpf selftest.
> 
> Reuse the sparc64 register handling on sparc32 but adapt the carry
> bit handling to use %tstate on sparc64 and %psr on sparc32.
> 
> 

Tested on a SPARC T7-1 (M7), 7.3-rc5 with the sparc64 series. The
64-bit seccomp_bpf gives the same result with this patch as without
it, pass:95 fail:0 skip:16. Built as a 32-bit binary against a sparc
Gentoo stage3, it gets the same result on the 64-bit kernel through
the compat path.

Tested-by: Stian Halseth <stian@itx.no> # sparc64, native and compat


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] sparc32: add seccomp filter support
  2026-10-14  8:07 [PATCH 0/3] sparc32: add seccomp filter support Ludwig Rydberg
                   ` (2 preceding siblings ...)
  2026-10-14  8:07 ` [PATCH 3/3] selftests/seccomp: add sparc32 support Ludwig Rydberg
@ 2026-10-14 16:36 ` Magnus Lindholm
  3 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2026-10-14 16:36 UTC (permalink / raw)
  To: Ludwig Rydberg
  Cc: Andreas Larsson, David S. Miller, Kees Cook, sparclinux,
	Andy Lutomirski, Will Drewry, Oleg Nesterov, Shuah Khan,
	linux-kselftest, linux-kernel, John Paul Adrian Glaubitz,
	Stian Halseth

Hi Ludwig,

On Wed, Oct 14, 2026 at 10:07 AM Ludwig Rydberg
<ludwig.rydberg@gaisler.com> wrote:
>
> This adds SECCOMP_FILTER support for sparc32 on top of Stian Halseth's
> sparc64 series (v2):
> https://lore.kernel.org/r/20260902072745.3412940-1-stian@itx.no
>
> Patch 1 splits syscall_trace() into syscall_trace_enter() and
> syscall_trace_leave() as on sparc64 and most other architectures.
>
> Patch 2 adds a call to seccomp_permit_syscall() in syscall_trace_enter()
> to filter system calls. A denied syscall skips the call and goes
> through the syscall exit work with the return value already set.
>
> Patch 3 extends the seccomp_bpf selftest's SPARC support to sparc32.
>
> Testing:
> seccomp_bpf on v7.3-rc1 with the whole seccomp series applied on a
> GR-CPCI-GR740 board from Frontgrade Gaisler:
>
> - UP: pass:99 fail:0 skip:12
> - SMP with out-of-tree patches that implement the futex atomic
>   operations with CASA on LEON: pass:99 fail:0 skip:12
> - SMP without them: pass:89 fail:10 skip:12.
>   FUTEX depends on !(SPARC32 && SMP) (see 3f2bedabb62c) and glibc aborts
>   with "The futex facility returned an unexpected error code" in the 10
>   tests that use threads (KILL_thread,
>   user_notification_filter_empty_threaded, tsync_vs_dead_thread_leader and
>   the 7 TSYNC tests).
>
> The 12 skipped tests need the UPROBES which sparc32 does not have.
>
> Ludwig Rydberg (3):
>   sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}()
>   sparc32: add seccomp filter support
>   selftests/seccomp: add sparc32 support
>
>  arch/sparc/Kconfig                            |  2 +-
>  arch/sparc/include/asm/thread_info_32.h       |  2 +
>  arch/sparc/kernel/entry.S                     | 33 ++++++++--------
>  arch/sparc/kernel/kernel.h                    |  3 +-
>  arch/sparc/kernel/ptrace_32.c                 | 26 ++++++++-----
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 38 +++++++++++++------
>  6 files changed, 66 insertions(+), 38 deletions(-)
>
>
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> prerequisite-patch-id: 5772aba3cb572833df13529ec6bb03ae9e848e25
> prerequisite-patch-id: 70a54ba398c763e45f9332ff4cc06b3f2a3e7825
> --
> 2.35.3
>
>

Tested the series on a dual-CPU HyperSPARC SPARCstation 20 with
my patched v7.3-rc1 kernel, including SMP futex support.

The cross-built seccomp_bpf selftests completed on real hardware:
92 passed, 0 failed, 19 skipped. The harness timeout was increased
to 180 seconds; test workloads were unchanged. No new kernel
messages or taint appeared.

Tested-by: Magnus Lindholm <linmag7@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] selftests/seccomp: add sparc32 support
  2026-10-14  8:07 ` [PATCH 3/3] selftests/seccomp: add sparc32 support Ludwig Rydberg
  2026-10-14  9:29   ` Stian Halseth
@ 2026-10-14 16:40   ` Kees Cook
  1 sibling, 0 replies; 7+ messages in thread
From: Kees Cook @ 2026-10-14 16:40 UTC (permalink / raw)
  To: Ludwig Rydberg
  Cc: Andreas Larsson, David S. Miller, sparclinux, Andy Lutomirski,
	Will Drewry, Oleg Nesterov, Shuah Khan, linux-kselftest,
	linux-kernel, John Paul Adrian Glaubitz, Stian Halseth

On Wed, Oct 14, 2026 at 10:07:30AM +0200, Ludwig Rydberg wrote:
> Add SPARC32 definitions to seccomp_bpf selftest.
> 
> Reuse the sparc64 register handling on sparc32 but adapt the carry
> bit handling to use %tstate on sparc64 and %psr on sparc32.
> 
> Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>

LGTM from a seccomp test perspective. Please feel free to carry this via
the sparc tree:

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-14 16:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14  8:07 [PATCH 0/3] sparc32: add seccomp filter support Ludwig Rydberg
2026-10-14  8:07 ` [PATCH 1/3] sparc32: Split common syscall_trace() to syscall_trace_{enter|leave}() Ludwig Rydberg
2026-10-14  8:07 ` [PATCH 2/3] sparc32: add seccomp filter support Ludwig Rydberg
2026-10-14  8:07 ` [PATCH 3/3] selftests/seccomp: add sparc32 support Ludwig Rydberg
2026-10-14  9:29   ` Stian Halseth
2026-10-14 16:40   ` Kees Cook
2026-10-14 16:36 ` [PATCH 0/3] sparc32: add seccomp filter support Magnus Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®