Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: fils: use cfg80211_find_ext_elem()

Replace the use of cfg80211_find_ext_ie() with the more
structured cfg80211_find_ext_elem().

Link: https://lore.kernel.org/r/20210930131130.17ecf37f0605.I853c2f9c2117a713deca9b8deb3552796d98ffac@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+12 -10
+12 -10
net/mac80211/fils_aead.c
··· 219 219 { 220 220 struct ieee80211_mgmt *mgmt = (void *)skb->data; 221 221 u8 *capab, *ies, *encr; 222 - const u8 *addr[5 + 1], *session; 222 + const u8 *addr[5 + 1]; 223 + const struct element *session; 223 224 size_t len[5 + 1]; 224 225 size_t crypt_len; 225 226 ··· 232 231 ies = mgmt->u.assoc_req.variable; 233 232 } 234 233 235 - session = cfg80211_find_ext_ie(WLAN_EID_EXT_FILS_SESSION, 236 - ies, skb->data + skb->len - ies); 237 - if (!session || session[1] != 1 + 8) 234 + session = cfg80211_find_ext_elem(WLAN_EID_EXT_FILS_SESSION, 235 + ies, skb->data + skb->len - ies); 236 + if (!session || session->datalen != 1 + 8) 238 237 return -EINVAL; 239 238 /* encrypt after FILS Session element */ 240 - encr = (u8 *)session + 2 + 1 + 8; 239 + encr = (u8 *)session->data + 1 + 8; 241 240 242 241 /* AES-SIV AAD vectors */ 243 242 ··· 271 270 { 272 271 struct ieee80211_mgmt *mgmt = (void *)frame; 273 272 u8 *capab, *ies, *encr; 274 - const u8 *addr[5 + 1], *session; 273 + const u8 *addr[5 + 1]; 274 + const struct element *session; 275 275 size_t len[5 + 1]; 276 276 int res; 277 277 size_t crypt_len; ··· 282 280 283 281 capab = (u8 *)&mgmt->u.assoc_resp.capab_info; 284 282 ies = mgmt->u.assoc_resp.variable; 285 - session = cfg80211_find_ext_ie(WLAN_EID_EXT_FILS_SESSION, 286 - ies, frame + *frame_len - ies); 287 - if (!session || session[1] != 1 + 8) { 283 + session = cfg80211_find_ext_elem(WLAN_EID_EXT_FILS_SESSION, 284 + ies, frame + *frame_len - ies); 285 + if (!session || session->datalen != 1 + 8) { 288 286 mlme_dbg(sdata, 289 287 "No (valid) FILS Session element in (Re)Association Response frame from %pM", 290 288 mgmt->sa); 291 289 return -EINVAL; 292 290 } 293 291 /* decrypt after FILS Session element */ 294 - encr = (u8 *)session + 2 + 1 + 8; 292 + encr = (u8 *)session->data + 1 + 8; 295 293 296 294 /* AES-SIV AAD vectors */ 297 295