wifi: cfg80211: wext: prevent encoding_size overflow in giwrange
A message that is not in the archive (sent off-list or not yet received): [email protected]
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.
--- net/wireless/wext-compat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/wireless/wext-compat.c +6 -4
@@ -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
Johannes Berg
maintainerQuoted 10 lines · Ren Wei
From: Yuqi Xu <[email protected]>
cfg80211_wext_giwrange()appends oneencoding_sizeentry for eachWLAN_CIPHER_SUITE_WEP40andWLAN_CIPHER_SUITE_WEP104value advertised by the wiphy. structiw_rangeonly providesIW_MAX_ENCODING_SIZESslots in encoding_size[], so duplicated WEP entries can advancenum_encoding_sizespast the end of the array and corrupt theiw_rangebuffer 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