Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 1-element array in drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h #230

Closed
GustavoARSilva opened this issue Oct 5, 2022 · 1 comment
Assignees
Labels
1-element array arg in memcpy() [Idiom] fake flexible array [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 1-element array Conversion away from one-element array

Comments

@GustavoARSilva
Copy link
Collaborator

Replace one-element array with flexible-array member in drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h

 933 /**
 934  * struct brcmf_dload_data_le - data passing to firmware for downloading
 935  * @flag: flags related to download data.
 936  * @dload_type: type of download data.
 937  * @len: length in bytes of download data.
 938  * @crc: crc of download data.
 939  * @data: download data.
 940  */
 941 struct brcmf_dload_data_le {
 942         __le16 flag;
 943         __le16 dload_type;
 944         __le32 len;
 945         __le32 crc;
 946         u8 data[1];
 947 };

Audit (at least) all these places where the flex array is being used:

diff -u -p ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
--- ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -154,7 +154,6 @@ static int brcmf_c_process_clm_blob(stru
                        chunk_len = datalen;
                        dl_flag |= DL_END;
                }
-               memcpy(chunk_buf->data, clm->data + cumulative_len, chunk_len);

                err = brcmf_c_download(ifp, dl_flag, chunk_buf, chunk_len);

@GustavoARSilva GustavoARSilva self-assigned this Oct 5, 2022
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 15, 2022
…in struct brcmf_dload_data_le

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element array with flexible-array
member in struct brcmf_dload_data_le.

Important to mention is that doing a build before/after this patch results
in no binary output differences.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy() and help us make progress towards globally enabling
-fstrict-flex-arrays=3 [1].

Link: KSPP#230
Link: KSPP#79
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
@GustavoARSilva
Copy link
Collaborator Author

@GustavoARSilva GustavoARSilva added the [PATCH] Exists A patch exists to address the issue label Nov 15, 2022
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Nov 22, 2022
…in struct brcmf_dload_data_le

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element array with flexible-array
member in struct brcmf_dload_data_le.

Important to mention is that doing a build before/after this patch results
in no binary output differences.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy() and help us make progress towards globally enabling
-fstrict-flex-arrays=3 [1].

Link: KSPP#230
Link: KSPP#79
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/905f5b68cf93c812360d081caae5b15221db09b6.1668548907.git.gustavoars@kernel.org
@GustavoARSilva GustavoARSilva added the [PATCH] Accepted A submitted patch has been accepted upstream label Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-element array arg in memcpy() [Idiom] fake flexible array [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 1-element array Conversion away from one-element array
Projects
None yet
Development

No branches or pull requests

1 participant