Skip to contentSkip to conversation

KVM: x86: remove bogus user-triggerable WARN_ON

PATCH In review Paolo Bonzini 3 participants 6 messages Mar 19, 2020 – Mar 20, 2020

Subsystems (3)
lore
Share & tools
lore

Paolo Bonzini

author maintainer
#0 lore raw

PATCH 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.

Reported-by [email protected]
Fixes 9446e6fce0ab ("KVM: x86: fix WARN_ON check of an unsigned less than zero")
Cc Sean Christopherson <[email protected]>
---
 arch/x86/kvm/x86.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kvm/x86.c +0 -1
index 3156e25b0774..d65ff2008cf1 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Paolo Bonzini

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.

Reported-by [email protected]
Fixes 9446e6fce0ab ("KVM: x86: fix WARN_ON check of an unsigned less than zero")
Cc Sean Christopherson <[email protected]>

---

#2 lore raw
In reply to Paolo Bonzini
Quoted 4 lines · Paolo Bonzini

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.

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

#3 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini

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.

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....

author maintainer
#4 lore raw
Quoted 8 lines · Thomas Gleixner
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini

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.

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

#5 lore raw
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Thomas Gleixner
Quoted 9 lines · Thomas Gleixner
Quoted 4 lines · Paolo Bonzini

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.

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_CLOCK and later rectifies it with the right value.

Yes please.