1: ad3d6e01c266 ! 1: bd2462141b83 wifi: nxpwifi: bound the pairwise-cipher OUI walk to the IE length @@ Metadata ## Commit message ## wifi: nxpwifi: bound the pairwise-cipher OUI walk to the IE length  - nxpwifi_search_oui_in_ie() takes the pairwise cipher suite count from the - RSN or WPA element of a beacon or probe response and compares that many - 4-byte suite selectors against the wanted one. The count is not checked - against the length of the element, and the beacon parser records the - element on its ID alone (the RSN case in nxpwifi_update_bss_desc_with_ie() - has no length check at all, the WPA one only requires the OUI and type). + nxpwifi_search_oui_in_ie() walks as many 4-byte cipher suites as the + pairwise count in the RSN or WPA element of a beacon says, without + checking the count against the element length. An AP can send a short + element with a large count and make the walk read up to 1020 bytes past + the end of the kmemdup()ed beacon buffer.  - An element which is shorter than its count claims therefore makes the - walk read up to 255 * 4 bytes past the element. The element lives in the - buffer nxpwifi_fill_new_bss_desc() kmemdup()s from the cfg80211 BSS - entry, which is exactly as long as the received elements, so an element - placed last reads past the end of the allocation. The walk runs from - nxpwifi_is_network_compatible() when a station with WPA or WPA2 enabled - connects to an HT-capable BSS, on data that the AP controls. - - mwifiex, which this code was derived from, had the same walk and was - fixed by commit e667aee1c192 ("wifi: mwifiex: bound the pairwise-cipher - OUI walk to the IE length"). Do the same here: pass the number of element - bytes available at the suite list and refuse a count that does not fit. - The length stays signed so that an element too short to hold even the - fixed part is rejected rather than wrapped. In nxpwifi the vendor header - keeps the OUI type in a field of its own, so both are subtracted to get - the bytes available in the WPA element. + Pass the number of element bytes available at the suite list and reject + a count that does not fit, as commit e667aee1c192 ("wifi: mwifiex: bound + the pairwise-cipher OUI walk to the IE length") did for mwifiex.  Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x") Cc: stable@vger.kernel.org - Assisted-by: LLM Signed-off-by: Paulneja   ## drivers/net/wireless/nxp/nxpwifi/scan.c ##