wifi: rtw89: fix IE length passed to cfg80211_find_ie()
Subsystems (2)
v2 cover wifi: rtw89: fix IE length passed to cfg80211_find_ie()
From: Tristan Madani <[email protected]>
Two callers of cfg80211_find_ie() in rtw89 pass skb->len as the IE data length, but since ies points past the management frame header and fixed fields, the correct length is skb->len minus the header offset. This causes cfg80211_find_ie() to potentially read past the IE data boundary.
Changes since v1:
- Straightened the cfg80211_find_ie() call in wow.c to a single line
- Removed unnecessary blank line in wow.c
Both per Ping-Ke Shih review feedback.
Tristan Madani (2):
wifi: rtw89: fix IE length passed to cfg80211_find_ie() in 6 GHz probe
wifi: rtw89: fix IE length passed to cfg80211_find_ie() in WoW AKM
drivers/net/wireless/realtek/rtw89/core.c | 6 +++++- drivers/net/wireless/realtek/rtw89/wow.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
--
2.47.3
PATCH v2 1/2 wifi: rtw89: fix IE length passed to cfg80211_find_ie() in 6 GHz probe
From: Tristan Madani <[email protected]>
rtw89_core_cancel_6ghz_probe_tx() computes a pointer to the IE area from a beacon/probe response frame:
ies = mgmt->u.beacon.variable;
but then passes skb->len as the IE data length to cfg80211_find_ie(). Since skb->len covers the entire frame including the 36-byte management header and fixed fields, cfg80211_find_ie() may read up to 36 bytes past the end of the actual IE data.
Fix by computing the correct IE data length as skb->len minus the header offset, and validating the minimum frame length before parsing.
--- drivers/net/wireless/realtek/rtw89/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/core.c +5 -1
@@ -2571,6 +2571,7 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;struct list_head *pkt_list = rtwdev->scan_info.pkt_list;struct rtw89_pktofld_info *info; + size_t hdr_len = offsetof(struct ieee80211_mgmt, u.beacon.variable);const u8 *ies = mgmt->u.beacon.variable, *ssid_ie;bool queue_work = false;
@@ -2582,7 +2583,10 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,return ; } - ssid_ie =cfg80211_find_ie (WLAN_EID_SSID , ies, skb->len); +if (skb->len < hdr_len) +return ; + + ssid_ie =cfg80211_find_ie (WLAN_EID_SSID , ies, skb->len - hdr_len);list_for_each_entry (info, &pkt_list[NL80211_BAND_6GHZ ], list) {if (ether_addr_equal (info->bssid, mgmt->bssid)) {
Signature · 1 line
2.47.3
Ping-Ke Shih
maintainerRE: [PATCH wireless v2 1/2] wifi: rtw89: fix IE length passed to cfg80211_find_ie() in 6 GHz probe
drivers/net/wireless/realtek/rtw89/core.c static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev, · line 2592
Quoted 12 lines · Tristan Madani
drivers/net/wireless/realtek/rtw89/core.c +4
-1@@ -2582,7 +2583,10 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,return ; } - ssid_ie =cfg80211_find_ie (WLAN_EID_SSID , ies, skb->len); +if (skb->len < hdr_len) +return ; + + ssid_ie =cfg80211_find_ie (WLAN_EID_SSID , ies, skb->len - hdr_len);list_for_each_entry (info, &pkt_list[NL80211_BAND_6GHZ ], list) {if (ether_addr_equal (info->bssid, mgmt->bssid)) {
The use of cfg80211_find_ie() was removed by [1]. Please use https://github.com/pkshih/rtw.git as codebase.
PATCH v2 2/2 wifi: rtw89: fix IE length passed to cfg80211_find_ie() in WoW AKM
In reply to Tristan MadaniFrom: Tristan Madani <[email protected]>
__rtw89_wow_parse_akm() computes a pointer to the IE area from an association request frame:
ies = mgmt->u.assoc_req.variable;
but then passes skb->len as the IE data length to cfg80211_find_ie(). Since skb->len covers the entire frame including the 28-byte management header and fixed fields, cfg80211_find_ie() may read past the end of the actual IE data.
Fix by computing the correct IE data length as skb->len minus the header offset, and validating the minimum frame length before parsing.
--- drivers/net/wireless/realtek/rtw89/wow.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/wow.c +5 -1
@@ -16,10 +16,14 @@ void __rtw89_wow_parse_akm(struct rtw89_dev *rtwdev, struct sk_buff *skb) {struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;struct rtw89_wow_param *rtw_wow = &rtwdev->wow; + size_t hdr_len = offsetof(struct ieee80211_mgmt, u.assoc_req.variable);const u8 *rsn, *ies = mgmt->u.assoc_req.variable;struct rtw89_rsn_ie *rsn_ie; - rsn =cfg80211_find_ie (WLAN_EID_RSN , ies, skb->len); +if (skb->len < hdr_len) +return ; + + rsn =cfg80211_find_ie (WLAN_EID_RSN , ies, skb->len - hdr_len);if (!rsn)return ;
Signature · 1 line
2.47.3
RE: [PATCH wireless v2 2/2] wifi: rtw89: fix IE length passed to cfg80211_find_ie() in WoW AKM
Quoted 12 lines · Tristan Madani
From: Tristan Madani <[email protected]>
__rtw89_wow_parse_akm()computes a pointer to the IE area from an association request frame:ies = mgmt->u.assoc_req.variable;but then passes
skb->lenas the IE data length tocfg80211_find_ie(). Sinceskb->lencovers the entire frame including the 28-byte management header and fixed fields,cfg80211_find_ie()may read past the end of the actual IE data.
Quoted 4 lines
Fix by computing the correct IE data length as
skb->lenminus the header offset, and validating the minimum frame length before parsing.Fixes 480dd4dddfc5 ("wifi: rtw89: enter power save mode aggressively")
it should be
Quoted 2 lines
Signed-off-by Tristan Madani <[email protected]>
Ping-Ke Shih
maintainerRe: [PATCH wireless v2 2/2] wifi: rtw89: fix IE length passed to cfg80211_find_ie() in WoW AKM
In reply to Tristan MadaniQuoted 12 lines · Tristan Madani
From: Tristan Madani <[email protected]>
__rtw89_wow_parse_akm()computes a pointer to the IE area from an association request frame:ies = mgmt->u.assoc_req.variable;but then passes
skb->lenas the IE data length tocfg80211_find_ie(). Sinceskb->lencovers the entire frame including the 28-byte management header and fixed fields,cfg80211_find_ie()may read past the end of the actual IE data.
Quoted 7 lines
Fix by computing the correct IE data length as
skb->lenminus the header offset, and validating the minimum frame length before parsing.Fixes 480dd4dddfc5 ("wifi: rtw89: enter power save mode aggressively")Signed-off-by Tristan Madani <[email protected]>Acked-by Ping-Ke Shih <[email protected]>
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
6c17c57d45ef wifi: rtw89: fix IE length passed to cfg80211_find_ie() in WoW AKM