[RFC PATCH 10/13] arch: Wire up rootns system calls

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 18 05:09:56 UTC 2026


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] arch: missing fork wrappers and copy_thread() handling for
  rootns_enter()
- [Medium] powerpc: syscalls: mark rootns syscalls as nospu instead of
  common
--

commit 6e1db5e1442ac6454b78c4391c7f17751ffafb5b
Author: Jarkko Sakkinen <jarkko at kernel.org>

arch: Wire up rootns system calls

This commit wires up the rootns_create(), rootns_wait(), rootns_kill(), and
rootns_enter() system calls across the architecture syscall tables and
asm-generic/unistd.h.

> diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl
> index 52e3538cc7df4..a945b15abe6dd 100644
> --- a/arch/alpha/kernel/syscalls/syscall.tbl
> +++ b/arch/alpha/kernel/syscalls/syscall.tbl
> @@ -512,3 +512,7 @@
>  580	common	listns				sys_listns
>  581	common	rseq_slice_yield		sys_rseq_slice_yield
>  582	common	fchroot				sys_fchroot
> +583	common	rootns_create			sys_rootns_create
> +584	common	rootns_wait			sys_rootns_wait
> +585	common	rootns_kill			sys_rootns_kill
> +586	common	rootns_enter			sys_rootns_enter

[Severity: High]
Does wiring rootns_enter directly to sys_rootns_enter corrupt the child
process's user registers and leak kernel stack contents on architectures that
require a fork-like entry wrapper?

sys_rootns_enter() calls kernel_clone() -> copy_process() -> copy_thread().
On Alpha, normal syscall entry (entSys) pops struct switch_stack before
calling the C handler, whereas fork, vfork, clone, and clone3 use fork_like
wrappers (alpha_clone3, etc.) to push struct switch_stack and call
__save_fpu().  Without that wrapper, copy_thread() copies
((struct switch_stack *)regs) - 1, which holds sys_rootns_enter()'s C stack
frame, into childstack and restores kernel stack words into the child's
r9-r15 registers in ret_from_fork.

The same issue affects the other architectures in this patch whose normal
syscall entry does not save callee-saved registers or register windows before
copy_thread():
- m68k needs a SAVE_SWITCH_STACK wrapper like __sys_clone3 so copy_thread()
  does not populate the child's switch_stack (d6-d7, a3-a6) from the C frame.
- MIPS (o32, n32, n64) needs save_static_function() so s0-s8 are saved into
  struct pt_regs before copy_thread().
- PA-RISC needs a fork_like wrapper like sys_clone3_wrapper to save r3-r18
  and cr27 into task->thread.regs.
- SPARC (32-bit and 64-bit) needs an assembly wrapper like __sys_clone3 /
  sparc_clone3 to flush register windows and call synchronize_user_stack(),
  and copy_thread() in process_32.c and process_64.c needs to check for
  __NR_rootns_enter alongside __NR_clone3 so it does not apply SunOS fork()
  return conventions (which set the child's %o0 to current->pid instead of 0
  and clobber %o1).
- ARC, Nios II, and OpenRISC (via include/uapi/asm-generic/unistd.h and
  scripts/syscall.tbl) likewise require their callee-saved register /
  switch_stack wrappers before calling sys_rootns_enter().

[ ... ]

> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl
> index cfbb70039ff00..610ceedd1a14c 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -563,3 +563,7 @@
>  470	common	listns				sys_listns
>  471	nospu	rseq_slice_yield		sys_rseq_slice_yield
>  472	common	fchroot				sys_fchroot
> +473	common	rootns_create			sys_rootns_create
> +474	common	rootns_wait			sys_rootns_wait			compat_sys_rootns_wait
> +475	common	rootns_kill			sys_rootns_kill
> +476	common	rootns_enter			sys_rootns_enter

[Severity: Medium]
Should the rootns syscalls, especially rootns_enter, be marked nospu instead
of common on PowerPC?

Entries marked common are included in spu_syscall_table[] and can be invoked
by a Cell SPU program via spu_process_callback() -> spu_sys_callback() while
the host PowerPC thread is inside spufs_run_spu().  Process creation and wait
syscalls (fork, vfork, clone, clone3, waitid) are marked nospu so an SPU
context cannot clone the host PPE thread from inside sys_spu_run().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117050841.3289652-1-jarkko@kernel.org?part=10



More information about the Linux-security-module-archive mailing list