mirror_ubuntu-kernels/drivers/net/wireless/broadcom/brcm80211
Hans de Goede 16e455a465 wifi: brcmfmac: Fix field-spanning write in brcmf_scan_params_v2_to_v1()
Using brcmfmac with 6.5-rc3 on a brcmfmac43241b4-sdio triggers
a backtrace caused by the following field-spanning warning:

memcpy: detected field-spanning write (size 120) of single field
  "&params_le->channel_list[0]" at
  drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:1072 (size 2)

The driver still works after this warning. The warning was introduced by the
new field-spanning write checks which were enabled recently.

Fix this by replacing the channel_list[1] declaration at the end of
the struct with a flexible array declaration.

Most users of struct brcmf_scan_params_le calculate the size to alloc
using the size of the non flex-array part of the struct + needed extra
space, so they do not care about sizeof(struct brcmf_scan_params_le).

brcmf_notify_escan_complete() however uses the struct on the stack,
expecting there to be room for at least 1 entry in the channel-list
to store the special -1 abort channel-id.

To make this work use an anonymous union with a padding member
added + the actual channel_list flexible array.

Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230729140500.27892-1-hdegoede@redhat.com
2023-08-02 13:34:16 +03:00
..
brcmfmac wifi: brcmfmac: Fix field-spanning write in brcmf_scan_params_v2_to_v1() 2023-08-02 13:34:16 +03:00
brcmsmac wifi: brcmsmac: fix gnu_printf warnings 2023-06-16 12:24:15 +03:00
brcmutil wifi: brcmutil: use helper function pktq_empty() instead of open code 2023-06-01 16:14:43 +03:00
include wifi: brcmfmac: pcie: Add IDs/properties for BCM4387 2023-02-27 16:59:35 +02:00
Kconfig brcmsmac: rework LED dependencies 2021-12-08 20:17:06 +02:00
Makefile brcmfmac: switch source files to using SPDX license identifier 2019-05-28 15:24:12 +03:00