wifi: cfg80211: fix out-of-bounds access during multi-link element defragmentation
authorVeerendranath Jakkam <quic_vjakkam@quicinc.com>
Thu, 24 Apr 2025 12:31:42 +0000 (18:01 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 6 May 2025 19:04:40 +0000 (21:04 +0200)
Currently during the multi-link element defragmentation process, the
multi-link element length added to the total IEs length when calculating
the length of remaining IEs after the multi-link element in
cfg80211_defrag_mle(). This could lead to out-of-bounds access if the
multi-link element or its corresponding fragment elements are the last
elements in the IEs buffer.

To address this issue, correctly calculate the remaining IEs length by
deducting the multi-link element end offset from total IEs end offset.

Cc: stable@vger.kernel.org
Fixes: 2481b5da9c6b ("wifi: cfg80211: handle BSS data contained in ML probe responses")
Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Link: https://patch.msgid.link/20250424-fix_mle_defragmentation_oob_access-v1-1-84412a1743fa@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/scan.c

index 9865f305275da6f265f0c305244953bb7e31f7bd..ddd3a97f6609d1ccf196730836b84d2a4d658120 100644 (file)
@@ -2681,7 +2681,7 @@ cfg80211_defrag_mle(const struct element *mle, const u8 *ie, size_t ielen,
        /* Required length for first defragmentation */
        buf_len = mle->datalen - 1;
        for_each_element(elem, mle->data + mle->datalen,
-                        ielen - sizeof(*mle) + mle->datalen) {
+                        ie + ielen - mle->data - mle->datalen) {
                if (elem->id != WLAN_EID_FRAGMENT)
                        break;