]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: Store full CSGSFS and SS register from mcontext
authorBenjamin Berg <benjamin@sipsolutions.net>
Mon, 24 Feb 2025 18:18:19 +0000 (19:18 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 18 Mar 2025 10:10:41 +0000 (11:10 +0100)
Doing this allows using registers as retrieved from an mcontext to be
pushed to a process using PTRACE_SETREGS.

It is not entirely clear to me why CSGSFS was masked. Doing so creates
issues when using the mcontext as process state in seccomp and simply
copying the register appears to work perfectly fine for ptrace.

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
Link: https://patch.msgid.link/20250224181827.647129-2-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/x86/um/os-Linux/mcontext.c

index d2f3a595b4ef163e024c9c6ed5a57c8110581f44..37decaa74761bc52df6c4ac67e3fe1db54c4186d 100644 (file)
@@ -28,8 +28,7 @@ void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
        COPY(RIP);
        COPY2(EFLAGS, EFL);
        COPY2(CS, CSGSFS);
-       regs->gp[CS / sizeof(unsigned long)] &= 0xffff;
-       regs->gp[CS / sizeof(unsigned long)] |= 3;
+       regs->gp[SS / sizeof(unsigned long)] = mc->gregs[REG_CSGSFS] >> 48;
 #endif
 }