]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: libertas: cap SSID len in lbs_associate()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 29 Aug 2025 12:48:35 +0000 (15:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:58:12 +0000 (18:58 +0200)
[ Upstream commit c786794bd27b0d7a5fd9063695df83206009be59 ]

If the ssid_eid[1] length is more that 32 it leads to memory corruption.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/2a40f5ec7617144aef412034c12919a4927d90ad.1756456951.git.dan.carpenter@linaro.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/marvell/libertas/cfg.c

index afe9bcd3ad46d7d37fdb0c138210f540e3173a19..37bb788f83e36e75b632533a41d6ec1f8559a34e 100644 (file)
@@ -1150,10 +1150,13 @@ static int lbs_associate(struct lbs_private *priv,
        /* add SSID TLV */
        rcu_read_lock();
        ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
-       if (ssid_eid)
-               pos += lbs_add_ssid_tlv(pos, ssid_eid + 2, ssid_eid[1]);
-       else
+       if (ssid_eid) {
+               u32 ssid_len = min(ssid_eid[1], IEEE80211_MAX_SSID_LEN);
+
+               pos += lbs_add_ssid_tlv(pos, ssid_eid + 2, ssid_len);
+       } else {
                lbs_deb_assoc("no SSID\n");
+       }
        rcu_read_unlock();
 
        /* add DS param TLV */