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: b1e1bd2e69 ("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>
This commit is contained in:
Benjamin Berg 2025-06-04 10:17:05 +02:00 committed by Johannes Berg
parent e92e255285
commit 942349413a
2 changed files with 1 additions and 5 deletions

View File

@ -296,10 +296,6 @@ static bool __init init_seccomp(void)
int n;
unsigned long sp;
/* doesn't work on 32-bit right now */
if (!IS_ENABLED(CONFIG_64BIT))
return false;
/*
* We check that we can install a seccomp filter and then exit(0)
* from a trapped syscall.

View File

@ -231,7 +231,7 @@ int set_stub_state(struct uml_pt_regs *regs, struct stub_data *data,
xstate_size = fp_size;
#endif
memcpy(fpstate_stub, &regs->fp, fp_size);
memcpy(xstate_stub, &regs->fp, xstate_size);
#ifdef __i386__
/*