Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: sisusbvga: Fix a potential UB casued by left shifting a negative value

The char buffer buf, receives data directly from user space,
so its content might be negative and its elements are left
shifted to form an unsigned integer.

Since left shifting a negative value is undefined behavior, thus
change the char to u8 to elimintate this UB.

Signed-off-by: Changming Liu <charley.ashbringer@gmail.com>
Link: https://lore.kernel.org/r/20200711043018.928-1-charley.ashbringer@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Changming Liu and committed by
Greg Kroah-Hartman
2b53a192 48025b4f

+1 -1
+1 -1
drivers/usb/misc/sisusbvga/sisusb.c
··· 761 761 u8 swap8, fromkern = kernbuffer ? 1 : 0; 762 762 u16 swap16; 763 763 u32 swap32, flag = (length >> 28) & 1; 764 - char buf[4]; 764 + u8 buf[4]; 765 765 766 766 /* if neither kernbuffer not userbuffer are given, assume 767 767 * data in obuf