mbox series

[v2,0/6,next] ath6kl: wmi: Replace one-element arrays with flexible-array members

Message ID cover.1645736204.git.gustavoars@kernel.org (mailing list archive)
Headers show
Series ath6kl: wmi: Replace one-element arrays with flexible-array members | expand

Message

Gustavo A. R. Silva Feb. 24, 2022, 9:15 p.m. UTC
This series aims to replace one-element arrays with flexible-array
members in multiple structures in drivers/net/wireless/ath/ath6kl/wmi.h

There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

This helps with the ongoing efforts to globally enable -Warray-bounds
and get us closer to being able to tighten the FORTIFY_SOURCE routines
on memcpy().

These issues were found with the help of Coccinelle and audited and fixed,
manually.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79

Changes in v2:
 - Revert changes in if-statement logic for all the affected patches:
	if (len < sizeof(struct foo))
   Link: https://lore.kernel.org/linux-hardening/3abb0846-a26f-3d76-8936-cd23cf4387f1@quicinc.com/ 
 - Update changelog texts.
 - Add Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com> tag.

Gustavo A. R. Silva (6):
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_begin_scan_cmd
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_start_scan_cmd
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_channel_list_reply
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_connect_event
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_disconnect_event
  ath6kl: wmi: Replace one-element array with flexible-array member in
    struct wmi_aplist_event

 drivers/net/wireless/ath/ath6kl/wmi.c | 22 ++++------------------
 drivers/net/wireless/ath/ath6kl/wmi.h | 12 ++++++------
 2 files changed, 10 insertions(+), 24 deletions(-)