From: Dan Carpenter <dan.carpenter@oracle.com>
To: Liran Alon <liran.alon@oracle.com>
Cc: "Wanpeng Li" <kernellwp@gmail.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH] KVM: LAPIC: Fix pv ipis out-of-bounds access
Date: Wed, 29 Aug 2018 13:12:05 +0300 [thread overview]
Message-ID: <20180829101205.jsp53e2wq7fc6ukd@mwanda> (raw)
In-Reply-To: <A523C29C-C3E8-4FEF-8620-96365F774582@oracle.com>
On Wed, Aug 29, 2018 at 12:05:06PM +0300, Liran Alon wrote:
> > arch/x86/kvm/lapic.c | 17 +++++++++++++----
> > 1 file changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index 0cefba2..86e933c 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -571,18 +571,27 @@ int kvm_pv_send_ipi(struct kvm *kvm, unsigned long ipi_bitmap_low,
> > rcu_read_lock();
> > map = rcu_dereference(kvm->arch.apic_map);
> >
> > + if (unlikely((s32)(map->max_apic_id - __fls(ipi_bitmap_low)) < min))
> > + goto out;
>
> I personally think “if ((min + __fls(ipi_bitmap_low)) > map->max_apic_id)” is more readable.
> But that’s just a matter of taste :)
That's an integer overflow.
But I do prefer to put the variable on the left. The truth is that some
Smatch checks just ignore code which is backwards written because
otherwise you have to write duplicate code and the most code is written
with the variable on the left.
if (min > (s32)(map->max_apic_id - __fls(ipi_bitmap_low))
Shouldn't this be >= instead? It looks off by one.
regards,
dan carpenter
next prev parent reply other threads:[~2018-08-29 10:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 5:52 [PATCH] KVM: LAPIC: Fix pv ipis out-of-bounds access Wanpeng Li
2018-08-29 9:05 ` Liran Alon
2018-08-29 10:12 ` Dan Carpenter [this message]
2018-08-29 10:18 ` Dan Carpenter
2018-08-29 10:23 ` Wanpeng Li
2018-08-29 10:29 ` Dan Carpenter
2018-08-29 10:42 ` Wanpeng Li
2018-08-29 10:54 ` Dan Carpenter
2018-08-29 10:43 ` Liran Alon
2018-08-29 13:55 ` Radim Krcmar
2018-08-29 14:36 ` Radim Krcmar
2018-08-29 15:42 ` Radim Krcmar
2018-08-30 2:15 ` Wanpeng Li
-- strict thread matches above, loose matches on Subject: below --
2018-08-29 5:51 Wanpeng Li
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=20180829101205.jsp53e2wq7fc6ukd@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox