mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: David Laight <David.Laight@ACULAB.COM>,
	'Sean Christopherson' <seanjc@google.com>
Cc: "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: Tue, 22 Dec 2020 23:49:15 +0100	[thread overview]
Message-ID: <64932096-22a8-27dd-a8d6-1e40f3119db4@redhat.com> (raw)
In-Reply-To: <01b7c21e3a864c0cb89fd036ebe03ccf@AcuMS.aculab.com>

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

Paolo


  reply	other threads:[~2020-12-22 22:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 10:21 Paolo Bonzini
2020-12-22 18:13 ` Sean Christopherson
2020-12-22 18:31   ` David Laight
2020-12-22 22:49     ` Paolo Bonzini [this message]
2020-12-23 16:59       ` Sean Christopherson

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=64932096-22a8-27dd-a8d6-1e40f3119db4@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seanjc@google.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

all inboxes | Powered by JetHome®