public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Laight <David.Laight@aculab.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.com" 
	<syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.com>
Subject: Re: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN
Date: Wed, 23 Dec 2020 08:59:51 -0800	[thread overview]
Message-ID: <X+N3h9b5ieAxl6n/@google.com> (raw)
In-Reply-To: <64932096-22a8-27dd-a8d6-1e40f3119db4@redhat.com>

On Tue, Dec 22, 2020, Paolo Bonzini wrote:
> On 22/12/20 19:31, David Laight wrote:
> > > 	/*
> > > 	 * Use 2ULL to incorporate the necessary +1 in the shift; adding +1 in
> > > 	 * the shift count will overflow SHL's max shift of 63 if s=0 and e=63.
> > > 	 */
> > A comment of the desired output value would be more use.
> > I think it is:
> > 	return 'e-s' ones followed by 's' zeros without shifting by 64.
> > 
> 
> What about a mix of the two:
> 
> 	/*
> 	 * Return 'e-s' ones followed by 's' zeros.  Note that the
> 	 * apparently obvious 1ULL << (e - s + 1) can shift by 64 if
> 	 * s=0 and e=63, which is undefined behavior.
> 	 */

Works for me, thanks!

      reply	other threads:[~2020-12-23 17:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 10:21 [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN Paolo Bonzini
2020-12-22 18:13 ` Sean Christopherson
2020-12-22 18:31   ` David Laight
2020-12-22 22:49     ` Paolo Bonzini
2020-12-23 16:59       ` Sean Christopherson [this message]

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=X+N3h9b5ieAxl6n/@google.com \
    --to=seanjc@google.com \
    --cc=David.Laight@aculab.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=syzbot+e87846c48bf72bc85311@syzkaller.appspotmail.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