mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86_64: Do not execute sysret with a non-canonical return address
Check for non-canonical guest RIP before attempting to execute sysret. If sysret is executed with a non-canonical value in RCX, Intel CPUs take the fault in ring0, but we will necessarily already have switched to the the user's stack pointer. This is a security vulnerability, XSA-7 / CVE-2012-0217. Signed-off-by: Jan Beulich <JBeulich@suse.com> Signed-off-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Tested-by: Ian Campbell <Ian.Campbell@citrix.com> Acked-by: Keir Fraser <keir.xen@gmail.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
46fce9fd2b
commit
6b091fa445
1 file changed
+11
@@ -40,6 +40,13 @@ restore_all_guest:
|
||||
testw $TRAP_syscall,4(%rsp)
|
||||
jz iret_exit_to_guest
|
||||
|
||||
/* Don't use SYSRET path if the return address is not canonical. */
|
||||
movq 8(%rsp),%rcx
|
||||
sarq $47,%rcx
|
||||
incl %ecx
|
||||
cmpl $1,%ecx
|
||||
ja .Lforce_iret
|
||||
|
||||
addq $8,%rsp
|
||||
popq %rcx # RIP
|
||||
popq %r11 # CS
|
||||
@@ -50,6 +57,10 @@ restore_all_guest:
|
||||
sysretq
|
||||
1: sysretl
|
||||
|
||||
.Lforce_iret:
|
||||
/* Mimic SYSRET behavior. */
|
||||
movq 8(%rsp),%rcx # RIP
|
||||
movq 24(%rsp),%r11 # RFLAGS
|
||||
ALIGN
|
||||
/* No special register assumptions. */
|
||||
iret_exit_to_guest:
|
||||
|
||||