linux-stable/drivers/net/ethernet/mellanox/mlx4
Zhou Qingyang addad76431 net/mlx4_en: Fix an use-after-free bug in mlx4_en_try_alloc_resources()
In mlx4_en_try_alloc_resources(), mlx4_en_copy_priv() is called and
tmp->tx_cq will be freed on the error path of mlx4_en_copy_priv().
After that mlx4_en_alloc_resources() is called and there is a dereference
of &tmp->tx_cq[t][i] in mlx4_en_alloc_resources(), which could lead to
a use after free problem on failure of mlx4_en_copy_priv().

Fix this bug by adding a check of mlx4_en_copy_priv()

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_MLX4_EN=m show no new warnings,
and our static analyzer no longer warns about this code.

Fixes: ec25bc04ed ("net/mlx4_en: Add resilience in low memory systems")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20211130164438.190591-1-zhou1615@umn.edu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-12-01 19:04:50 -08:00
..
alloc.c
catas.c
cmd.c ethernet: Remove redundant 'flush_workqueue()' calls 2021-10-10 11:33:15 +01:00
cq.c net/mlx4: Use array_size() helper in copy_to_user() 2021-09-29 11:32:14 +01:00
crdump.c
en_clock.c
en_cq.c
en_dcb_nl.c
en_ethtool.c net/mlx4_en: Update reported link modes for 1/10G 2021-11-29 13:03:32 +00:00
en_main.c ethernet: Remove redundant 'flush_workqueue()' calls 2021-10-10 11:33:15 +01:00
en_netdev.c net/mlx4_en: Fix an use-after-free bug in mlx4_en_try_alloc_resources() 2021-12-01 19:04:50 -08:00
en_port.c net/mlx4_en: Add XDP_REDIRECT statistics 2021-09-30 14:14:30 +01:00
en_port.h
en_resources.c
en_rx.c net/mlx4_en: Add XDP_REDIRECT statistics 2021-09-30 14:14:30 +01:00
en_selftest.c
en_tx.c net/mlx4_en: avoid one cache line miss to ring doorbell 2021-10-04 12:50:13 +01:00
eq.c
fw.c mlx4: replace mlx4_mac_to_u64() with ether_addr_to_u64() 2021-10-05 13:15:35 +01:00
fw.h RDMA/mlx4: Do not map the core_clock page to user space unless enabled 2021-06-03 14:19:53 -03:00
fw_qos.c
fw_qos.h
icm.c
icm.h
intf.c
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
main.c devlink: Delete reload enable/disable interface 2021-10-12 16:29:17 -07:00
Makefile
mcg.c mlx4: constify args for const dev_addr 2021-10-05 13:15:35 +01:00
mlx4.h net/mlx4: Treat VFs fair when handling comm_channel_events 2021-04-22 14:59:26 -07:00
mlx4_en.h net/mlx4_en: avoid one cache line miss to ring doorbell 2021-10-04 12:50:13 +01:00
mlx4_stats.h net/mlx4_en: Add XDP_REDIRECT statistics 2021-09-30 14:14:30 +01:00
mr.c
pd.c
port.c net/mlx4: Fix EEPROM dump support 2021-05-10 14:34:39 -07:00
profile.c
qp.c net/mlx4: Use ARRAY_SIZE to get an array's size 2021-08-18 15:16:54 -07:00
reset.c
resource_tracker.c net/mlx4: Fix fall-through warning for Clang 2021-06-29 08:17:23 -05:00
sense.c
srq.c