linux_dsm_epyc7002/drivers/net/wireless/rsi
Tobin C. Harding 44f98a9332 rsi: Remove stack VLA usage
The use of stack Variable Length Arrays needs to be avoided, as they
can be a vector for stack exhaustion, which can be both a runtime bug
(kernel Oops) or a security flaw (overwriting memory beyond the
stack). Also, in general, as code evolves it is easy to lose track of
how big a VLA can get. Thus, we can end up having runtime failures
that are hard to debug. As part of the directive[1] to remove all VLAs
from the kernel, and build with -Wvla.

Currently rsi code uses a VLA based on a function argument to
`rsi_sdio_load_data_master_write()`.  The function call chain is

Both these functions

	rsi_sdio_reinit_device()
	rsi_probe()

start the call chain:

	rsi_hal_device_init()
	rsi_load_fw()
	auto_fw_upgrade()
	ping_pong_write()
	rsi_sdio_load_data_master_write()

[Without familiarity with the code] it appears that none of the 4 locks

	mutex
	rx_mutex
	tx_mutex
	tx_bus_mutex

are held when `rsi_sdio_load_data_master_write()` is called.  It is therefore
safe to use kmalloc with GFP_KERNEL.

We can avoid using the VLA by using `kmalloc()` and free'ing the memory on all
exit paths.

Change buffer from 'u8 array' to 'u8 *'.  Call `kmalloc()` to allocate memory for
the buffer.  Using goto statement to call `kfree()` on all return paths.

It can be expected that this patch will result in a small increase in overhead
due to the use of `kmalloc()` however this code is only called on initialization
(and re-initialization) so this overhead should not degrade performance.

[1] https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-03-27 11:04:32 +03:00
..
Kconfig Bluetooth: btrsi: rework dependencies 2018-03-27 10:11:58 +03:00
Makefile rsi: add coex support 2018-03-13 18:36:57 +02:00
rsi_91x_coex.c rsi: handle BT traffic in driver 2018-03-13 18:37:06 +02:00
rsi_91x_core.c rsi: handle BT traffic in driver 2018-03-13 18:37:06 +02:00
rsi_91x_debugfs.c rsi: add version information 2017-09-25 11:25:23 +03:00
rsi_91x_hal.c rsi: handle BT traffic in driver 2018-03-13 18:37:06 +02:00
rsi_91x_mac80211.c rsi: fix kbuild reported build errors with CONFIG_PM off 2017-11-02 19:38:14 +02:00
rsi_91x_main.c rsi: add module parameter operating mode 2018-03-13 18:37:09 +02:00
rsi_91x_mgmt.c rsi: add coex support 2018-03-13 18:36:57 +02:00
rsi_91x_ps.c rsi: rsi_91x_ps: remove redundant code in str_psstate 2017-11-10 04:36:10 +02:00
rsi_91x_sdio_ops.c rsi: improve RX handling in SDIO interface 2018-03-13 18:42:24 +02:00
rsi_91x_sdio.c rsi: Remove stack VLA usage 2018-03-27 11:04:32 +03:00
rsi_91x_usb_ops.c rsi: improve RX packet handling in USB interface 2018-03-13 18:42:26 +02:00
rsi_91x_usb.c rsi: improve RX packet handling in USB interface 2018-03-13 18:42:26 +02:00
rsi_boot_params.h rsi: configure new boot parameters to device 2017-06-21 18:26:26 +03:00
rsi_coex.h rsi: add coex support 2018-03-13 18:36:57 +02:00
rsi_common.h rsi: add module parameter operating mode 2018-03-13 18:37:09 +02:00
rsi_debugfs.h
rsi_hal.h rsi: improve RX packet handling in USB interface 2018-03-13 18:42:26 +02:00
rsi_main.h rsi: improve RX packet handling in USB interface 2018-03-13 18:42:26 +02:00
rsi_mgmt.h rsi: add coex support 2018-03-13 18:36:57 +02:00
rsi_ps.h rsi: disallow power save config when AP vap running 2017-09-20 15:38:57 +03:00
rsi_sdio.h rsi: improve RX handling in SDIO interface 2018-03-13 18:42:24 +02:00
rsi_usb.h rsi: improve RX packet handling in USB interface 2018-03-13 18:42:26 +02:00