KVM: x86: remove bogus user-triggerable WARN_ON
Paolo Bonzini
maintainerPATCH 1/1 KVM: x86: remove bogus user-triggerable WARN_ON
The WARN_ON is essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage to KVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.
--- arch/x86/kvm/x86.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kvm/x86.c +0 -1
@@ -2444,7 +2444,6 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) vcpu->hv_clock.tsc_timestamp = tsc_timestamp; vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset; vcpu->last_guest_tsc = tsc_timestamp; -WARN_ON ((s64 )vcpu->hv_clock.system_time <0 );/* If the host uses TSC clocksource, then it is stable */ pvclock_flags =0 ;
Signature · 1 line
2.18.2
Quoted 10 lines · Paolo Bonzini
The
WARN_ONis essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage toKVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.Reported-by [email protected]Fixes 9446e6fce0ab ("KVM: x86: fix WARN_ON check of an unsigned less than zero")Cc Sean Christopherson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
Quoted 4 lines · Paolo Bonzini
The
WARN_ONis essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage toKVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.
Yes, it's a user provided value and it's completely unchecked. If that value is bogus then the guest will go sideways because timekeeping is completely busted. At least you should explain WHY you don't care.
Thanks,
tglx
Quoted 9 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini
The
WARN_ONis essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage toKVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.Yes, it's a user provided value and it's completely unchecked. If that value is bogus then the guest will go sideways because timekeeping is completely busted. At least you should explain WHY you don't care.
Or why it does not matter....
Paolo Bonzini
maintainerQuoted 8 lines · Thomas Gleixner
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini
The
WARN_ONis essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage toKVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.
Quoted 5 lines
Quoted 3 lines
Yes, it's a user provided value and it's completely unchecked. If that value is bogus then the guest will go sideways because timekeeping is completely busted. At least you should explain WHY you don't care.
Or why it does not matter....
I can change the commit message to "Guests can break if you do so, but the same applies to every KVM_SET_* ioctl". It's impossible to be sure that userspace doesn't ever send a bogus KVM_SET_CLOCK and later rectifies it with the right value.
Paolo
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Thomas Gleixner
Quoted 9 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini
The
WARN_ONis essentially comparing a user-provided value with 0. It is trivial to trigger it just by passing garbage toKVM_SET_CLOCK. Guests can break if you do so, but if it hurts when you do like this just do not do it.Yes, it's a user provided value and it's completely unchecked. If that value is bogus then the guest will go sideways because timekeeping is completely busted. At least you should explain WHY you don't care.
Quoted 6 lines
Quoted 1 line
Or why it does not matter....
I can change the commit message to "Guests can break if you do so, but the same applies to every KVM_SET_* ioctl". It's impossible to be sure that userspace doesn't ever send a bogus
KVM_SET_CLOCKand later rectifies it with the right value.
Yes please.