2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 12:43:55 +08:00
linux-next/drivers/staging
Tim Sell a5eb2188f5 staging: unisys: visorbus: address theoretical int overflows
Add necessary casting to several places where we were doing 32-bit
arithmetic (unsigned) to produce a 64-bit (unsigned long) result, to
prevent the theoretical possibility of a 32-bit overflow during the
arithmetic.

FYI, these are unsigned long:

	ctx->param_bytes
	ctx->allocbytes

These are unsigned int:

	bytes
	phdr->name_offset
	phdr->name_length

Here is the test program demonstrating why we really need the casts:

void main()
{
	unsigned int i;
	unsigned long il;

	printf("sizeof(int) =%dn",sizeof(i));
	printf("sizeof(long)=%dn",sizeof(il));

	i = (unsigned int)((((unsigned long)(1)) << 32) - 1);
	printf("i                     = %un", i);
	il = i+1;
	printf("adding 1 withOUT cast = %lun", il);
	il = (unsigned long)i+1;
	printf("adding 1 WITH    cast = %lun", il);
}
[selltc@mac tmp]$ gcc x.c -o x.out
[selltc@mac tmp]$ ./x.out
sizeof(int) =4
sizeof(long)=8
i                     = 4294967295
adding 1 withOUT cast = 0
adding 1 WITH    cast = 4294967296

Signed-off-by: Tim Sell <Timothy.Sell@unisys.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: David Binder <david.binder@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 14:20:50 +01:00
..
android staging: android: Remove redundant license text 2017-11-28 13:20:48 +01:00
board License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ccree staging: ccree: fix incorrect indentation of break statement 2017-11-27 09:20:40 +01:00
clocking-wizard
comedi staging: comedi: Remove redundant license text 2017-11-28 13:20:46 +01:00
dgnc staging: dgnc: Fix usleep_range is preferred over udelay 2017-11-27 09:20:40 +01:00
emxx_udc
fbtft Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
fsl-dpaa2 staging: fsl-dpaa2/eth: Extra headroom in RX buffers 2017-11-03 16:19:27 +01:00
fsl-mc staging: fsl-mc: use 32bits to support 64K size mc-portals 2017-11-28 13:58:31 +01:00
fwserial Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
gdm724x Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
goldfish staging: goldfish: (Coding Style) Fixed parenthesis alignment. 2017-08-31 18:21:37 +02:00
greybus treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
gs_fpgaboot staging: gs_fpgaboot: pr_err() strings should end with newlines 2017-10-03 18:36:25 +02:00
iio Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
ipx ipx: move Novell IPX protocol support into staging 2017-11-28 13:55:00 +01:00
irda staging/irda/net: Drop extraneous parentheses around test 2017-11-28 14:20:50 +01:00
ks7010 Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
lustre staging: lustre: Fix line over 80 characters 2017-11-28 14:14:44 +01:00
media staging: imx: use ktime_t for timestamps 2017-11-28 13:52:48 +01:00
most staging: most: make DEVICE_ATTR structures static 2017-11-28 13:36:21 +01:00
mt29f_spinand staging: mt29f_spinand: Enable the read ECC before program the page 2017-09-18 12:25:31 +02:00
ncpfs ncpfs: move net/ncpfs to drivers/staging/ncpfs 2017-11-28 13:55:01 +01:00
netlogic staging: net: netlogic: Fix alignment issue 2017-10-18 16:17:14 +02:00
nvec License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
octeon staging: octeon: fix line over 80 characters 2017-08-18 15:57:17 -07:00
octeon-usb
olpc_dcon License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pi433 staging: pi433: pi433_if.c codestyle fix 2017-11-28 14:11:49 +01:00
rtl8188eu Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
rtl8192e Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
rtl8192u treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
rtl8712 staging: rtl8712: remove redundant zero assignment to val32 2017-11-28 14:07:15 +01:00
rtl8723bs Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
rtlwifi staging: rtl8822be: fix missing null check on dev_alloc_skb return 2017-11-28 14:20:50 +01:00
rts5208 staging: rts5208: remove rtsx_read_pci_cfg_byte() 2017-11-28 14:20:50 +01:00
skein License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sm750fb staging/sm750fb: Add "port to atomic kms" to TODO 2017-11-28 13:52:48 +01:00
speakup staging: speakup: selection: replace _manual_ swap with swap macro 2017-11-27 09:20:40 +01:00
typec staging: typec: tcpci: mark expected switch fall-through in tcpci_to_typec_cc 2017-10-18 16:42:28 +02:00
unisys staging: unisys: visorbus: address theoretical int overflows 2017-11-28 14:20:50 +01:00
vboxvideo main drm pull request for v4.15 2017-11-15 20:42:10 -08:00
vc04_services staging: bcm2835-camera use ktime_t for timestamps 2017-11-28 13:52:48 +01:00
vme Staging/IIO patches for 4.15-rc1 2017-11-13 20:53:28 -08:00
vt6655 staging: vt6655: Remove redundant license text 2017-11-28 13:20:47 +01:00
vt6656 staging: vt6656: Remove redundant license text 2017-11-28 13:20:47 +01:00
wilc1000 staging: wilc1000: add SPDX identifiers to all wilc100 files 2017-11-28 13:20:46 +01:00
wlan-ng staging: wlan-ng: add SPDX identifiers to all wlan-ng driver files 2017-11-28 13:20:47 +01:00
xgifb staging: xgifb: add SPDX identifiers to the remaining holdout file 2017-11-28 13:20:46 +01:00
Kconfig ncpfs: move net/ncpfs to drivers/staging/ncpfs 2017-11-28 13:55:01 +01:00
Makefile ncpfs: move net/ncpfs to drivers/staging/ncpfs 2017-11-28 13:55:01 +01:00