Skip to content

Commit 428b8f1

Browse files
nickdesaulniersbonzini
authored andcommitted
KVM: VMX: don't allow memory operands for inline asm that modifies SP
THUNK_TARGET defines [thunk_target] as having "rm" input constraints when CONFIG_RETPOLINE is not set, which isn't constrained enough for this specific case. For inline assembly that modifies the stack pointer before using this input, the underspecification of constraints is dangerous, and results in an indirect call to a previously pushed flags register. In this case `entry`'s stack slot is good enough to satisfy the "m" constraint in "rm", but the inline assembly in handle_external_interrupt_irqoff() modifies the stack pointer via push+pushf before using this input, which in this case results in calling what was the previous state of the flags register, rather than `entry`. Be more specific in the constraints by requiring `entry` be in a register, and not a memory operand. Reported-by: Dmitry Vyukov <[email protected]> Reported-by: [email protected] Debugged-by: Alexander Potapenko <[email protected]> Debugged-by: Paolo Bonzini <[email protected]> Debugged-by: Sean Christopherson <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent edec6e0 commit 428b8f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6287,7 +6287,7 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
62876287
#endif
62886288
ASM_CALL_CONSTRAINT
62896289
:
6290-
THUNK_TARGET(entry),
6290+
[thunk_target]"r"(entry),
62916291
[ss]"i"(__KERNEL_DS),
62926292
[cs]"i"(__KERNEL_CS)
62936293
);

0 commit comments

Comments
 (0)