Skip to contentSkip to conversation

wifi: cfg80211: wext: prevent encoding_size overflow in giwrange

PATCH In review Ren Wei 2 participants 2 messages Apr 2 – Apr 7 1 message not in the archive 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ren Wei

author
#1 lore raw

PATCH 1/1 wifi: cfg80211: wext: prevent encoding_size overflow in giwrange

From: Yuqi Xu <[email protected]>

cfg80211_wext_giwrange() appends one encoding_size entry for each WLAN_CIPHER_SUITE_WEP40 and WLAN_CIPHER_SUITE_WEP104 value advertised by the wiphy. struct iw_range only provides IW_MAX_ENCODING_SIZES slots in encoding_size[], so duplicated WEP entries can advance num_encoding_sizes past the end of the array and corrupt the iw_range buffer returned by SIOCGIWRANGE.

This can happen when the wiphy cipher list contains duplicated WEP entries.

Only append encoding sizes while there is still room in the fixed-size array. This keeps the current behaviour for normal cipher lists and truncates oversized WEP capability lists instead of writing past the end of the buffer.

Fixes 2ab658f9ce21 ("cfg80211: set WE encoding size based on available ciphers")
---
 net/wireless/wext-compat.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/wireless/wext-compat.c +6 -4
index 5a70a0120343..9c5ac7da774c 100644
@@ -170,13 +170,15 @@ int cfg80211_wext_giwrange(struct net_device *dev,
 			break;
 
 		case WLAN_CIPHER_SUITE_WEP40:
-			range->encoding_size[range->num_encoding_sizes++] =
-				WLAN_KEY_LEN_WEP40;
+			if (range->num_encoding_sizes < IW_MAX_ENCODING_SIZES)
+				range->encoding_size[range->num_encoding_sizes++] =
+					WLAN_KEY_LEN_WEP40;
 			break;
 
 		case WLAN_CIPHER_SUITE_WEP104:
-			range->encoding_size[range->num_encoding_sizes++] =
-				WLAN_KEY_LEN_WEP104;
+			if (range->num_encoding_sizes < IW_MAX_ENCODING_SIZES)
+				range->encoding_size[range->num_encoding_sizes++] =
+					WLAN_KEY_LEN_WEP104;
 			break;
 		}
 	}
Signature · 1 line
2.52.0
maintainer
#2 lore raw
Quoted 10 lines · Ren Wei

From: Yuqi Xu <[email protected]>

cfg80211_wext_giwrange() appends one encoding_size entry for each WLAN_CIPHER_SUITE_WEP40 and WLAN_CIPHER_SUITE_WEP104 value advertised by the wiphy. struct iw_range only provides IW_MAX_ENCODING_SIZES slots in encoding_size[], so duplicated WEP entries can advance num_encoding_sizes past the end of the array and corrupt the iw_range buffer returned by SIOCGIWRANGE.

This can happen when the wiphy cipher list contains duplicated WEP entries.

That's pretty ridiculous though, even if it can (right now) be reached through hwsim.

Probably better to just make cfg80211 reject duplicate entries though than specifically hacking wext...

johannes