97c2803c9c
In linux-2.6.16, we have noticed a problem where the gs base value returned from an arch_prtcl(ARCH_GET_GS, ...) call will be incorrect if: - the current/calling task has NOT set its own gs base yet to a non-zero value, - some other task that ran on the same processor previously set their own gs base to a non-zero value. In this situation, the ARCH_GET_GS code will read and return the MSR_KERNEL_GS_BASE msr register. However, since the __switch_to() code does NOT load/zero the MSR_KERNEL_GS_BASE register when the task that is switched IN has a zero next->gs value, the caller of arch_prctl(ARCH_GET_GS, ...) will get back the value of some previous tasks's gs base value instead of 0. Change the arch_prctl() ARCH_GET_GS code to only read and return the MSR_KERNEL_GS_BASE msr register if the 'gs' register of the calling task is non-zero. Side note: Since in addition to using arch_prctl(ARCH_SET_GS, ...), a task can also setup a gs base value by using modify_ldt() and write an index value into 'gs' from user space, the patch below reads 'gs' instead of using thread.gs, since in the modify_ldt() case, the thread.gs value will be 0, and incorrect value would be returned (the task->thread.gs value). When the user has not set its own gs base value and the 'gs' register is zero, then the MSR_KERNEL_GS_BASE register will not be read and a value of zero will be returned by reading and returning 'task->thread.gs'. The first patch shown below is an attempt at implementing this approach. Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org> |
||
---|---|---|
.. | ||
acpi | ||
cpufreq | ||
aperture.c | ||
apic.c | ||
asm-offsets.c | ||
crash_dump.c | ||
crash.c | ||
e820.c | ||
early_printk.c | ||
entry.S | ||
functionlist | ||
genapic_cluster.c | ||
genapic_flat.c | ||
genapic.c | ||
head64.c | ||
head.S | ||
i387.c | ||
i8259.c | ||
init_task.c | ||
io_apic.c | ||
ioport.c | ||
irq.c | ||
kprobes.c | ||
ldt.c | ||
machine_kexec.c | ||
Makefile | ||
mce_amd.c | ||
mce_intel.c | ||
mce.c | ||
module.c | ||
mpparse.c | ||
nmi.c | ||
pci-dma.c | ||
pci-gart.c | ||
pci-nommu.c | ||
pci-swiotlb.c | ||
pmtimer.c | ||
process.c | ||
ptrace.c | ||
reboot.c | ||
relocate_kernel.S | ||
setup64.c | ||
setup.c | ||
signal.c | ||
smp.c | ||
smpboot.c | ||
suspend_asm.S | ||
suspend.c | ||
sys_x86_64.c | ||
syscall.c | ||
time.c | ||
trampoline.S | ||
traps.c | ||
vmlinux.lds.S | ||
vsmp.c | ||
vsyscall.c | ||
x8664_ksyms.c |