KVM: arm64: vgic: drop WARN from vgic_get_irq
PATCH 1/1 KVM: arm64: vgic: drop WARN from vgic_get_irq
vgic_get_irq(intid) is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g., KVM_IRQ_LINE for intid 1020).
Drop the WARN call from vgic_get_irq.
--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)
arch/arm64/kvm/vgic/vgic.c +0 -1
@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid); -WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );return NULL ; }
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
Hi Ricardo,
Quoted 18 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.Signed-off-by Ricardo Koller <[email protected]>--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)arch/arm64/kvm/vgic/vgic.c +0
-0
arch/arm64/kvm/vgic/vgic.c struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 109
Quoted 4 lines
arch/arm64/kvm/vgic/vgic.c +0
-1@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid); -WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );
Could we maybe downgrade the message to WARN_ONCE() (to get a stack) or pr_warn_ratelimited()? I agree it is problematic that userspace can cause this WARN to fire, but it'd be helpful for debugging too.
--
Thanks,
Oliver
Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c +0
-1return NULL ; } --2.33.0.rc2.250.ged5fa647cd-goog
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 24 lines · Oliver Upton
Hi Ricardo,
Quoted 21 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.Signed-off-by Ricardo Koller <[email protected]>--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)arch/arm64/kvm/vgic/vgic.c +0
-0@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid);
Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 109
Quoted 1 line
arch/arm64/kvm/vgic/vgic.c +0
-1-WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );Could we maybe downgrade the message to
WARN_ONCE()(to get a stack) orpr_warn_ratelimited()? I agree it is problematic that userspace can cause this WARN to fire, but it'd be helpful for debugging too.
Was thinking about that, until I found this in bug.h:
/*
* WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
* significant kernel issues that need prompt attention if they should ever
* appear at runtime.
*
* Do not use these macros when checking for invalid external inputs
* (e.g. invalid system call arguments, or invalid data coming from
* network/devices),
Just in case, KVM_IRQ_LINE returns -EINVAL for an invalid intid (like 1020). I think it's more appropriate for the vmm to log it. What do you think?
Thanks,
Ricardo
Quoted 10 lines
--
Thanks,
OliverQuoted 6 lines
arch/arm64/kvm/vgic/vgic.c +0
-1return NULL ; } --2.33.0.rc2.250.ged5fa647cd-goog
Quoted 44 lines · Ricardo Koller
Quoted 24 lines · Oliver Upton
Hi Ricardo,
Quoted 21 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.Signed-off-by Ricardo Koller <[email protected]>--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)arch/arm64/kvm/vgic/vgic.c +0
-0@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid);Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 109
Quoted 1 line
arch/arm64/kvm/vgic/vgic.c +0
-1-WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );Could we maybe downgrade the message to
WARN_ONCE()(to get a stack) orpr_warn_ratelimited()? I agree it is problematic that userspace can cause this WARN to fire, but it'd be helpful for debugging too.Was thinking about that, until I found this in
bug.h:/*
*WARN(),WARN_ON(),WARN_ON_ONCE, and so on can be used to report
* significant kernel issues that need prompt attention if they should ever
* appear at runtime.
*
* Do not use these macros when checking for invalid external inputs
* (e.g. invalid system call arguments, or invalid data coming from
* network/devices),
Quoted 3 lines
Just in case,
KVM_IRQ_LINEreturns-EINVALfor an invalid intid (like 1020). I think it's more appropriate for the vmm to log it. What do you think?
vgic_get_irq() is called in a bunch of other places though, right? IOW, intid doesn't necessarily come from userspace. In fact, I believe KVM_IRQ_LINE is the only place we pass a value from userspace to vgic_get_irq() (don't quote me on that).
Perhaps instead the fix could be to explicitly check that the intid from userspace is valid and exit early rather than count on vgic_get_irq() to do the right thing.
--
Thanks,
Oliver
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c +0
-1return NULL ; } --2.33.0.rc2.250.ged5fa647cd-goog
Marc Zyngier
maintainerQuoted 50 lines · Oliver Upton
Quoted 44 lines · Ricardo Koller
Quoted 24 lines · Oliver Upton
Hi Ricardo,
Quoted 21 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.Signed-off-by Ricardo Koller <[email protected]>--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)arch/arm64/kvm/vgic/vgic.c +0
-0@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid);Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 109
Quoted 1 line
arch/arm64/kvm/vgic/vgic.c +0
-1-WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );Could we maybe downgrade the message to
WARN_ONCE()(to get a stack) orpr_warn_ratelimited()? I agree it is problematic that userspace can cause this WARN to fire, but it'd be helpful for debugging too.Was thinking about that, until I found this in
bug.h:/*
*WARN(),WARN_ON(),WARN_ON_ONCE, and so on can be used to report
* significant kernel issues that need prompt attention if they should ever
* appear at runtime.
*
* Do not use these macros when checking for invalid external inputs
* (e.g. invalid system call arguments, or invalid data coming from
* network/devices),Quoted 3 lines
Just in case,
KVM_IRQ_LINEreturns-EINVALfor an invalid intid (like 1020). I think it's more appropriate for the vmm to log it. What do you think?
Quoted 8 lines
vgic_get_irq()is called in a bunch of other places though, right? IOW, intid doesn't necessarily come from userspace. In fact, I believeKVM_IRQ_LINEis the only place we pass a value from userspace tovgic_get_irq()(don't quote me on that).Perhaps instead the fix could be to explicitly check that the intid from userspace is valid and exit early rather than count on
vgic_get_irq()to do the right thing.
vgic_get_irq() is designed to do the right thing. Returning NULL is the way it reports an error, and this NULL value is already checked at when directly provided either by the VMM or the guest. If we missed any of those, that would be what needs addressing. Obtaining a NULL pointer is a good way to catch those.
In general, the kernel log is not how we report userspace errors (we have been there before...). It is slow, noisy, unclear and ultimately leaks information. If you really want something, then a pr_debug is a potential tool as it can be dynamically enabled with the right configuration.
Thanks,
M.
Signature · 5 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Oliver Upton
Reviewed-byQuoted 68 lines · Marc Zyngier
Quoted 50 lines · Oliver Upton
Quoted 44 lines · Ricardo Koller
Quoted 24 lines · Oliver Upton
Hi Ricardo,
Quoted 21 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.Signed-off-by Ricardo Koller <[email protected]>--- arch/arm64/kvm/vgic/vgic.c | 1 - 1 file changed, 1 deletion(-)arch/arm64/kvm/vgic/vgic.c +0
-0@@ -106,7 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu,if (intid >=VGIC_MIN_LPI )return vgic_get_lpi (kvm, intid);Quoted 6 lines
arch/arm64/kvm/vgic/vgic.c struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, · line 109
Quoted 1 line
arch/arm64/kvm/vgic/vgic.c +0
-1-WARN (1 ,"Looking up struct vgic_irq for reserved INTID" );Could we maybe downgrade the message to
WARN_ONCE()(to get a stack) orpr_warn_ratelimited()? I agree it is problematic that userspace can cause this WARN to fire, but it'd be helpful for debugging too.Was thinking about that, until I found this in
bug.h:/*
*WARN(),WARN_ON(),WARN_ON_ONCE, and so on can be used to report
* significant kernel issues that need prompt attention if they should ever
* appear at runtime.
*
* Do not use these macros when checking for invalid external inputs
* (e.g. invalid system call arguments, or invalid data coming from
* network/devices),Quoted 3 lines
Just in case,
KVM_IRQ_LINEreturns-EINVALfor an invalid intid (like 1020). I think it's more appropriate for the vmm to log it. What do you think?Quoted 8 lines
vgic_get_irq()is called in a bunch of other places though, right? IOW, intid doesn't necessarily come from userspace. In fact, I believeKVM_IRQ_LINEis the only place we pass a value from userspace tovgic_get_irq()(don't quote me on that).Perhaps instead the fix could be to explicitly check that the intid from userspace is valid and exit early rather than count on
vgic_get_irq()to do the right thing.
vgic_get_irq()is designed to do the right thing. Returning NULL is the way it reports an error, and this NULL value is already checked at when directly provided either by the VMM or the guest. If we missed any of those, that would be what needs addressing. Obtaining a NULL pointer is a good way to catch those.
Quoted 3 lines
In general, the kernel log is not how we report userspace errors (we have been there before...). It is slow, noisy, unclear and ultimately leaks information.
Absolutely. My comments were aimed at calls to vgic_get_irq() where intid is coming from the kernel, not userspace. That being said, probably no good reason to buy a full fat WARN() in a function such as this one. I'm done waffling on this one liner now :)
Quoted 10 lines
If you really want something, then a
pr_debugis a potential tool as it can be dynamically enabled with the right configuration.Thanks,
M.--
Without deviation from the norm, progress is not possible.
Quoted 6 lines · Ricardo Koller
vgic_get_irq(intid)is used all over the vgic code in order to get a reference to a struct irq. It warns whenever intid is not a valid number (like when it's a reserved IRQ number). The issue is that this warning can be triggered from userspace (e.g.,KVM_IRQ_LINEfor intid 1020).Drop the WARN call from
vgic_get_irq.
Applied to next, thanks!
[1/1] KVM: arm64: vgic: drop WARN from vgic_get_irq
commit: b9a51949cebcd57bfb9385d9da62ace52564898c
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.