OpenCloudOS-Kernel/drivers/net/ethernet/mellanox/mlx4
Jack Morgenstein 8511a653e9 net/mlx4_core: Fix qp mtt size calculation
Calculation of qp mtt size (in function mlx4_RST2INIT_wrapper)
ultimately depends on function roundup_pow_of_two.

If the amount of memory required by the QP is less than one page,
roundup_pow_of_two is called with argument zero.  In this case, the
roundup_pow_of_two result is undefined.

Calling roundup_pow_of_two with a zero argument resulted in the
following stack trace:

UBSAN: Undefined behaviour in ./include/linux/log2.h:61:13
shift exponent 64 is too large for 64-bit type 'long unsigned int'
CPU: 4 PID: 26939 Comm: rping Tainted: G OE 4.19.0-rc1
Hardware name: Supermicro X9DR3-F/X9DR3-F, BIOS 3.2a 07/09/2015
Call Trace:
dump_stack+0x9a/0xeb
ubsan_epilogue+0x9/0x7c
__ubsan_handle_shift_out_of_bounds+0x254/0x29d
? __ubsan_handle_load_invalid_value+0x180/0x180
? debug_show_all_locks+0x310/0x310
? sched_clock+0x5/0x10
? sched_clock+0x5/0x10
? sched_clock_cpu+0x18/0x260
? find_held_lock+0x35/0x1e0
? mlx4_RST2INIT_QP_wrapper+0xfb1/0x1440 [mlx4_core]
mlx4_RST2INIT_QP_wrapper+0xfb1/0x1440 [mlx4_core]

Fix this by explicitly testing for zero, and returning one if the
argument is zero (assuming that the next higher power of 2 in this case
should be one).

Fixes: c82e9aa0a8 ("mlx4_core: resource tracking for HCA resources used by guests")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-03-12 15:00:15 -07:00
..
Kconfig net: devlink: turn devlink into a built-in 2019-02-26 08:49:05 -08:00
Makefile net/mlx4_core: Add Crdump FW snapshot support 2018-07-12 17:37:13 -07:00
alloc.c mellanox: Switch to bitmap_zalloc() 2019-03-04 10:19:33 -08:00
catas.c net/mlx4_core: Add Crdump FW snapshot support 2018-07-12 17:37:13 -07:00
cmd.c net/mlx4_core: Fix locking in SRIOV mode when switching between events and polling 2019-03-12 15:00:15 -07:00
cq.c net/mlx4_core: Fix error handling when initializing CQ bufs in the driver 2019-01-24 21:48:26 -08:00
crdump.c net/mlx4_core: Use devlink region_snapshot parameter 2018-07-12 17:37:13 -07:00
en_clock.c
en_cq.c net/mlx4_en: remove fallback after kzalloc_node() 2018-12-17 11:18:02 -08:00
en_dcb_nl.c net/mlx4_en: Fix mixed PFC and Global pause user control requests 2018-03-27 12:02:30 -04:00
en_ethtool.c net/mlx4_core: Correctly set PFC param if global pause is turned off. 2018-12-08 21:26:36 -08:00
en_main.c net/mlx4_en: Use minimal rx and tx ring sizes on kdump kernel 2018-10-09 11:08:48 -07:00
en_netdev.c net/mlx4_en: fix spelling mistake: "quiting" -> "quitting" 2019-02-18 12:06:42 -08:00
en_port.c net/mlx4_en: Add physical RX/TX bytes/packets counters 2018-02-27 14:53:26 -05:00
en_port.h
en_resources.c net/mlx4: Fix endianness issue in qp context params 2017-10-09 10:33:05 -07:00
en_rx.c net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames 2019-02-12 12:58:48 -05:00
en_selftest.c net/mlx4_en: Fix selftest for small MTUs 2017-12-13 16:38:36 -05:00
en_tx.c net/mlx4_en: remove fallback after kzalloc_node() 2018-12-17 11:18:02 -08:00
eq.c net/mlx4_core: A write memory barrier is sufficient in EQ ci update 2019-01-24 21:54:13 -08:00
fw.c net/mlx4_core: Add masking for a few queries on HCA caps 2019-01-24 21:48:26 -08:00
fw.h net/mlx4_core: Add health buffer address capability 2018-07-12 17:37:13 -07:00
fw_qos.c net/mlx4: fix spelling mistake: "availible" -> "available" 2017-08-16 14:23:45 -07:00
fw_qos.h net/mlx4: fix spelling mistake: "availible" -> "available" 2017-08-16 14:23:45 -07:00
icm.c net/mlx4: replace pci_{,un}map_sg with dma_{,un}map_sg 2019-01-07 05:14:17 -08:00
icm.h net/mlx4: Get rid of page operation after dma_alloc_coherent 2019-01-07 05:14:17 -08:00
intf.c net/mlx4: fix spelling mistake: "Inrerface" -> "Interface" and rephrase message 2018-05-23 14:58:10 -04:00
main.c devlink: publish params only after driver init is done 2019-02-08 15:02:49 -08:00
mcg.c net/mlx4/mcg: Mark expected switch fall-throughs 2018-08-07 17:54:20 -07:00
mlx4.h net/mlx4: Fix UBSAN warning of signed integer overflow 2018-11-15 16:09:31 -08:00
mlx4_en.h net/mlx4_en: Change min MTU size to ETH_MIN_MTU 2018-12-03 16:16:22 -08:00
mlx4_stats.h net/mlx4_en: Add physical RX/TX bytes/packets counters 2018-02-27 14:53:26 -05:00
mr.c net/mlx4_core: Zero out lkey field in SW2HW_MPT fw command 2018-11-15 16:09:30 -08:00
pd.c
port.c net: ethernet: mlx4: Remove unnecessary parentheses 2018-06-04 10:14:39 -04:00
profile.c net/mlx4_core: Allow MTTs starting at any index 2018-07-25 16:30:38 -07:00
qp.c net/mlx4: Fix irq-unsafe spinlock usage 2018-05-23 15:48:58 -04:00
reset.c
resource_tracker.c net/mlx4_core: Fix qp mtt size calculation 2019-03-12 15:00:15 -07:00
sense.c
srq.c drivers, net, mlx4: convert mlx4_srq.refcount from atomic_t to refcount_t 2017-10-22 02:22:38 +01:00