[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <X+N3h9b5ieAxl6n/@google.com>
Date: Wed, 23 Dec 2020 08:59:51 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: David Laight <David.Laight@...lab.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"syzbot+e87846c48bf72bc85311@...kaller.appspotmail.com"
<syzbot+e87846c48bf72bc85311@...kaller.appspotmail.com>
Subject: Re: [PATCH] KVM: x86: fix shift out of bounds reported by UBSAN
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!
Powered by blists - more mailing lists