]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mwifiex: Fix memcpy() field-spanning write warning in mwifiex_cmd_802_11_scan_ext()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Wed, 21 Aug 2024 21:23:51 +0000 (15:23 -0600)
committerKalle Valo <kvalo@kernel.org>
Mon, 9 Sep 2024 12:09:00 +0000 (15:09 +0300)
Replace one-element array with a flexible-array member in
`struct host_cmd_ds_802_11_scan_ext`.

With this, fix the following warning:

elo 16 17:51:58 surfacebook kernel: ------------[ cut here ]------------
elo 16 17:51:58 surfacebook kernel: memcpy: detected field-spanning write (size 243) of single field "ext_scan->tlv_buffer" at drivers/net/wireless/marvell/mwifiex/scan.c:2239 (size 1)
elo 16 17:51:58 surfacebook kernel: WARNING: CPU: 0 PID: 498 at drivers/net/wireless/marvell/mwifiex/scan.c:2239 mwifiex_cmd_802_11_scan_ext+0x83/0x90 [mwifiex]

Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Closes: https://lore.kernel.org/linux-hardening/ZsZNgfnEwOcPdCly@black.fi.intel.com/
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/ZsZa5xRcsLq9D+RX@elsanto
drivers/net/wireless/marvell/mwifiex/fw.h
drivers/net/wireless/marvell/mwifiex/scan.c

index e91def0afa14d0cd6d9a5f86041f1790de5f5119..d03129d5d24e3deeddbe20903c53f73b547c10c0 100644 (file)
@@ -1627,7 +1627,7 @@ struct host_cmd_ds_802_11_scan_rsp {
 
 struct host_cmd_ds_802_11_scan_ext {
        u32   reserved;
-       u8    tlv_buffer[1];
+       u8    tlv_buffer[];
 } __packed;
 
 struct mwifiex_ie_types_bss_mode {
index 010e6ff91457f7e951748439fba1ca8563ca279b..cab889af4c4a62b04aadae5eb40e8b3cc8addf66 100644 (file)
@@ -2534,8 +2534,7 @@ int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
        ext_scan_resp = &resp->params.ext_scan;
 
        tlv = (void *)ext_scan_resp->tlv_buffer;
-       buf_left = le16_to_cpu(resp->size) - (sizeof(*ext_scan_resp) + S_DS_GEN
-                                             - 1);
+       buf_left = le16_to_cpu(resp->size) - (sizeof(*ext_scan_resp) + S_DS_GEN);
 
        while (buf_left >= sizeof(struct mwifiex_ie_types_header)) {
                type = le16_to_cpu(tlv->type);