git: d78164c83a67 - stable/13 - LinuxKPI: 802.11: deal with scan_ie_len

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 29 Nov 2023 16:38:53 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=d78164c83a672c000b01f5f5a5a45b782284fea6

commit d78164c83a672c000b01f5f5a5a45b782284fea6
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-10-27 20:41:43 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-11-29 16:36:11 +0000

    LinuxKPI: 802.11: deal with scan_ie_len
    
    We only need to reserve the extra space for DSSS if
    NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES is set, so add the conditional.
    Also add checks in case scan_ie_len will grow beyond the maximum.
    Given this is currently unlikely, leave the cleanup for later as
    some other restructuring should be done first.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 78ca45df310563ca46448a124674e0542aab2e31)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 2292339ef9ba..b605cb36ad88 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -3919,20 +3919,30 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 	lhw->scan_ie_len = 2 + IEEE80211_RATE_SIZE;
 	if (lhw->max_rates > IEEE80211_RATE_SIZE)
 		lhw->scan_ie_len += 2 + (lhw->max_rates - IEEE80211_RATE_SIZE);
-	/*
-	 * net80211 does not seem to support the DSSS Parameter Set but some of
-	 * the drivers insert it so calculate the extra fixed space in.
-	 */
-	lhw->scan_ie_len += 2 + 1;
+
+	if (hw->wiphy->features & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) {
+		/*
+		 * net80211 does not seem to support the DSSS Parameter Set but
+		 * some of the drivers insert it so calculate the extra fixed
+		 * space in.
+		 */
+		lhw->scan_ie_len += 2 + 1;
+	}
 
 	/* Reduce the max_scan_ie_len "left" by the amount we consume already. */
-	if (hw->wiphy->max_scan_ie_len > 0)
+	if (hw->wiphy->max_scan_ie_len > 0) {
+		if (lhw->scan_ie_len > hw->wiphy->max_scan_ie_len)
+			goto err;
 		hw->wiphy->max_scan_ie_len -= lhw->scan_ie_len;
+	}
 
 	if (bootverbose)
 		ieee80211_announce(ic);
 
 	return (0);
+err:
+	IMPROVE("TODO FIXME CLEANUP");
+	return (-EAGAIN);
 }
 
 void