mirror_ubuntu-kernels/drivers/net/wireless/broadcom/brcm80211
Gustavo A. R. Silva 62d19b3580 wifi: brcmfmac: fweh: Add __counted_by for struct brcmf_fweh_queue_item and use struct_size()
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

Also, relocate `event->datalen = datalen;` to before calling
`memcpy(event->data, data, datalen);`, so that the __counted_by
annotation has effect, and flex-array member `data` can be properly
bounds-checked at run-time.

While there, use struct_size() helper, instead of the open-coded
version, to calculate the size for the allocation of the whole
flexible structure, including of course, the flexible-array member.

This code was found with the help of Coccinelle, and audited and
fixed manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/ZSRzrIe0345eymk2@work
2023-10-11 12:20:58 +03:00
..
brcmfmac wifi: brcmfmac: fweh: Add __counted_by for struct brcmf_fweh_queue_item and use struct_size() 2023-10-11 12:20:58 +03:00
brcmsmac wifi: brcmsmac: cleanup SCB-related data types 2023-08-02 13:11:07 +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