i386/148344: [patch] i386 mcontext has fsbase and gsbase fields swapped

Tijl Coosemans tijl at coosemans.org
Sat Jul 3 16:20:01 UTC 2010


>Number:         148344
>Category:       i386
>Synopsis:       [patch] i386 mcontext has fsbase and gsbase fields swapped
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 03 16:20:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Tijl Coosemans
>Release:        FreeBSD 8.1-PRERELEASE i386
>Organization:
>Environment:
>Description:
When setting up the i386 mcontext (e.g. when delivering a signal)
FreeBSD stores fsbase in the gsbase field and gsbase in the fsbase
field.
>How-To-Repeat:
>Fix:

--- patch-fsgsbase begins here ---
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 502aa4f..872d09b 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -645,10 +645,10 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
 	/*
 	 * Unconditionally fill the fsbase and gsbase into the mcontext.
 	 */
-	sdp = &td->td_pcb->pcb_gsd;
+	sdp = &td->td_pcb->pcb_fsd;
 	sf.sf_uc.uc_mcontext.mc_fsbase = sdp->sd_hibase << 24 |
 	    sdp->sd_lobase;
-	sdp = &td->td_pcb->pcb_fsd;
+	sdp = &td->td_pcb->pcb_gsd;
 	sf.sf_uc.uc_mcontext.mc_gsbase = sdp->sd_hibase << 24 |
 	    sdp->sd_lobase;
 
@@ -3255,9 +3255,9 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
 	 * mcontext after mc_fpstate.
 	 */
 	get_fpcontext(td, mcp);
-	sdp = &td->td_pcb->pcb_gsd;
-	mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase;
 	sdp = &td->td_pcb->pcb_fsd;
+	mcp->mc_fsbase = sdp->sd_hibase << 24 | sdp->sd_lobase;
+	sdp = &td->td_pcb->pcb_gsd;
 	mcp->mc_gsbase = sdp->sd_hibase << 24 | sdp->sd_lobase;
 
 	return (0);
--- patch-fsgsbase ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-i386 mailing list