Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: fix SECCOMP 32bit xstate register restore

There was a typo that caused the extended FP state to be copied into the
wrong location on 32 bit. On 32 bit we only store the xstate internally
as that already contains everything. However, for compatibility, the
mcontext on 32 bit first contains the legacy FP state and then the
xstate.

The code copied the xstate on top of the legacy FP state instead of
using the correct offset. This offset was already calculated in the
xstate_* variables, so simply switch to those to fix the problem.

With this SECCOMP mode works on 32 bit, so lift the restriction.

Fixes: b1e1bd2e6943 ("um: Add helper functions to get/set state for SECCOMP")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20250604081705.934112-1-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Benjamin Berg and committed by
Johannes Berg
94234941 e92e2552

+1 -5
-4
arch/um/os-Linux/start_up.c
··· 296 296 int n; 297 297 unsigned long sp; 298 298 299 - /* doesn't work on 32-bit right now */ 300 - if (!IS_ENABLED(CONFIG_64BIT)) 301 - return false; 302 - 303 299 /* 304 300 * We check that we can install a seccomp filter and then exit(0) 305 301 * from a trapped syscall.
+1 -1
arch/x86/um/os-Linux/mcontext.c
··· 231 231 xstate_size = fp_size; 232 232 #endif 233 233 234 - memcpy(fpstate_stub, &regs->fp, fp_size); 234 + memcpy(xstate_stub, &regs->fp, xstate_size); 235 235 236 236 #ifdef __i386__ 237 237 /*