]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rsi: avoid reading TKIP MIC keys for non-TKIP ciphers
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Wed, 1 Jul 2026 05:34:14 +0000 (13:34 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 6 Jul 2026 12:11:08 +0000 (14:11 +0200)
rsi_hal_load_key() copies tx_mic_key and rx_mic_key from data[16] and
data[24] whenever key data is present. Those offsets are only part of
the 32-byte TKIP key layout. Shorter keys used by other ciphers, such as
CCMP, do not provide those bytes, so the unconditional copies can read
past the supplied key buffer.

Only copy the MIC keys for TKIP, and reject malformed TKIP keys that are
shorter than the expected 32-byte layout.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260701053414.34015-1-pengpeng@iscas.ac.cn
[drop useless length check]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/rsi/rsi_91x_mgmt.c

index 7f2c1608f2ce3946cab8eb2b3048923afaea90c4..2ddf4d158bfe3e322cffdb6344714cf9172427f1 100644 (file)
@@ -848,8 +848,10 @@ int rsi_hal_load_key(struct rsi_common *common,
                } else {
                        memcpy(&set_key->key[0][0], data, key_len);
                }
-               memcpy(set_key->tx_mic_key, &data[16], 8);
-               memcpy(set_key->rx_mic_key, &data[24], 8);
+               if (cipher == WLAN_CIPHER_SUITE_TKIP) {
+                       memcpy(set_key->tx_mic_key, &data[16], 8);
+                       memcpy(set_key->rx_mic_key, &data[24], 8);
+               }
        } else {
                memset(&set_key[FRAME_DESC_SZ], 0, frame_len - FRAME_DESC_SZ);
        }