From: Oliver Upton <oupton@google.com> To: Ricardo Koller <ricarkol@google.com> Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, maz@kernel.org, james.morse@arm.com, Alexandru.Elisei@arm.com, drjones@redhat.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, jingzhangos@google.com, pshier@google.com, rananta@google.com, reijiw@google.com Subject: Re: [PATCH] KVM: arm64: vgic: drop WARN from vgic_get_irq Date: Thu, 19 Aug 2021 00:41:19 -0700 [thread overview] Message-ID: <CAOQ_Qsgy7d7pWc=0AHpR2LHO67Z=gCa-TV46NxXMsFP8yqOzTw@mail.gmail.com> (raw) In-Reply-To: <YR1/YEY8DX+r05nt@google.com> On Wed, Aug 18, 2021 at 2:45 PM Ricardo Koller <ricarkol@google.com> wrote: > > On Wed, Aug 18, 2021 at 02:34:03PM -0700, Oliver Upton wrote: > > Hi Ricardo, > > > > On Wed, Aug 18, 2021 at 2:32 PM Ricardo Koller <ricarkol@google.com> wrote: > > > > > > 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. > > > > > > Signed-off-by: Ricardo Koller <ricarkol@google.com> > > > --- > > > arch/arm64/kvm/vgic/vgic.c | 1 - > > > 1 file changed, 1 deletion(-) > > > > > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > > > index 111bff47e471..81cec508d413 100644 > > > --- a/arch/arm64/kvm/vgic/vgic.c > > > +++ b/arch/arm64/kvm/vgic/vgic.c > > > @@ -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. > > > > 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? 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 > > > return NULL; > > > } > > > > > > -- > > > 2.33.0.rc2.250.ged5fa647cd-goog > > >
WARNING: multiple messages have this Message-ID (diff)
From: Oliver Upton <oupton@google.com> To: Ricardo Koller <ricarkol@google.com> Cc: kvm@vger.kernel.org, maz@kernel.org, rananta@google.com, pshier@google.com, catalin.marinas@arm.com, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH] KVM: arm64: vgic: drop WARN from vgic_get_irq Date: Thu, 19 Aug 2021 00:41:19 -0700 [thread overview] Message-ID: <CAOQ_Qsgy7d7pWc=0AHpR2LHO67Z=gCa-TV46NxXMsFP8yqOzTw@mail.gmail.com> (raw) In-Reply-To: <YR1/YEY8DX+r05nt@google.com> On Wed, Aug 18, 2021 at 2:45 PM Ricardo Koller <ricarkol@google.com> wrote: > > On Wed, Aug 18, 2021 at 02:34:03PM -0700, Oliver Upton wrote: > > Hi Ricardo, > > > > On Wed, Aug 18, 2021 at 2:32 PM Ricardo Koller <ricarkol@google.com> wrote: > > > > > > 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. > > > > > > Signed-off-by: Ricardo Koller <ricarkol@google.com> > > > --- > > > arch/arm64/kvm/vgic/vgic.c | 1 - > > > 1 file changed, 1 deletion(-) > > > > > > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c > > > index 111bff47e471..81cec508d413 100644 > > > --- a/arch/arm64/kvm/vgic/vgic.c > > > +++ b/arch/arm64/kvm/vgic/vgic.c > > > @@ -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. > > > > 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? 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 > > > return NULL; > > > } > > > > > > -- > > > 2.33.0.rc2.250.ged5fa647cd-goog > > > _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2021-08-19 7:41 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-18 21:32 [PATCH] KVM: arm64: vgic: drop WARN from vgic_get_irq Ricardo Koller 2021-08-18 21:32 ` Ricardo Koller 2021-08-18 21:34 ` Oliver Upton 2021-08-18 21:34 ` Oliver Upton 2021-08-18 21:45 ` Ricardo Koller 2021-08-18 21:45 ` Ricardo Koller 2021-08-19 7:41 ` Oliver Upton [this message] 2021-08-19 7:41 ` Oliver Upton 2021-08-19 8:04 ` Marc Zyngier 2021-08-19 8:04 ` Marc Zyngier 2021-08-19 8:16 ` Oliver Upton 2021-08-19 8:16 ` Oliver Upton 2021-08-19 10:47 ` Marc Zyngier 2021-08-19 10:47 ` Marc Zyngier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAOQ_Qsgy7d7pWc=0AHpR2LHO67Z=gCa-TV46NxXMsFP8yqOzTw@mail.gmail.com' \ --to=oupton@google.com \ --cc=Alexandru.Elisei@arm.com \ --cc=catalin.marinas@arm.com \ --cc=drjones@redhat.com \ --cc=james.morse@arm.com \ --cc=jingzhangos@google.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=maz@kernel.org \ --cc=pshier@google.com \ --cc=rananta@google.com \ --cc=reijiw@google.com \ --cc=ricarkol@google.com \ --cc=suzuki.poulose@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.