From 3f3c90a958c5abf8ec0ed5d1fad2e40bd9905a50 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Thu, 24 Nov 2022 13:59:08 +0000 Subject: 15206 setcontext(2) should not restore %fsbase Reviewed by: Robert Mustacchi Reviewed by: Toomas Soome Approved by: Patrick Mooney --- usr/src/lib/libc/port/threads/sigaction.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'usr/src/lib') diff --git a/usr/src/lib/libc/port/threads/sigaction.c b/usr/src/lib/libc/port/threads/sigaction.c index 571e211f97..1417c1e18a 100644 --- a/usr/src/lib/libc/port/threads/sigaction.c +++ b/usr/src/lib/libc/port/threads/sigaction.c @@ -24,6 +24,10 @@ * Use is subject to license terms. */ +/* + * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + */ + #include "lint.h" #include /* @@ -563,7 +567,13 @@ setcontext(const ucontext_t *ucp) #if defined(__sparc) uc.uc_mcontext.gregs[REG_G7] = (greg_t)self; #elif defined(__amd64) - uc.uc_mcontext.gregs[REG_FS] = (greg_t)0; /* null for fsbase */ + /* + * 64-bit processes must have a selector value of zero for %fs + * in order to use the 64-bit fs_base (the full 64-bit address + * range cannot be expressed in a long mode descriptor). + */ + uc.uc_mcontext.gregs[REG_FS] = (greg_t)0; + uc.uc_mcontext.gregs[REG_FSBASE] = (greg_t)self; #elif defined(__i386) uc.uc_mcontext.gregs[GS] = (greg_t)LWPGS_SEL; #else -- cgit v1.2.3