Module Name: src Committed By: maxv Date: Sun Mar 24 13:15:43 UTC 2019
Modified Files: src/sys/arch/amd64/amd64: machdep.c src/sys/compat/linux/arch/amd64: linux_machdep.c Log Message: Fix a tiny race in setregs and linux_setregs. Between the moment we set pcb_flags to zero, and the moment cpu_segregs64_zero resets pcb_gs, we may be preempted. If this happens, and if the calling LWP was a 32bit thread, when switching back to that LWP, the context switcher sees that PCB_COMPAT32 is not set in pcb_flags and tries to perform a 64bit context switch; but pcb_gs contains a 32bit GDT descriptor, and not a 64bit GS.base value. The wrmsr therefore faults because the value is non-canonical, and this fault is fatal. Rearrange the code so that the update of pcb_flags and pcb_gs/pcb_fs is non interruptible. This fixes the problem, tested with a reproducer (which therefore doesn't work anymore). Likely fixes PR/53993. To generate a diff of this commit: cvs rdiff -u -r1.327 -r1.328 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.56 -r1.57 src/sys/compat/linux/arch/amd64/linux_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.