Re: [PATCH v2] KVM: x86: fix undefined behavior in bit shift for __feature_bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Again; please go fix your toolchain and don't quote broken crap like
this to change the code.

I'm fine with the changes, but there is no UB here, don't pretend there
is.

I have made patch v3 and submitted it, removed the UBSAN warning calltrace,
thanks for taking time review patch!

On 2022/11/1 16:44, Peter Zijlstra wrote:
On Tue, Nov 01, 2022 at 10:28:28AM +0800, Gaosheng Cui wrote:
Shifting signed 32-bit value by 31 bits is undefined, so we fix it
with the BIT() macro, at the same time, we change the input to
unsigned, and replace "/ 32" with ">> 5".

The UBSAN warning calltrace like below:

UBSAN: shift-out-of-bounds in arch/x86/kvm/reverse_cpuid.h:101:11
left shift of 1 by 31 places cannot be represented in type 'int'
Again; please go fix your toolchain and don't quote broken crap like
this to change the code.

I'm fine with the changes, but there is no UB here, don't pretend there
is.

.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux