[PATCH 2/2] nl80211: Avoid sending unsupported attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Benjamin Berg <benjamin.berg@xxxxxxxxx>

The kernel will reject commands if newer attributes are included even
though they should not be. Add appropriate checks in set_ap.

Signed-off-by: Benjamin Berg <benjamin.berg@xxxxxxxxx>
---
 src/drivers/driver_nl80211.c | 6 ++++--
 src/drivers/driver_nl80211.h | 5 +++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index b56ca852d3..27129c94ef 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -5189,7 +5189,8 @@ static int wpa_driver_nl80211_set_ap(void *priv,
 
 		flags |= NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT;
 
-		if (nla_put_u32(msg, NL80211_ATTR_AP_SETTINGS_FLAGS, flags))
+		if (nl80211_attr_supported(drv, NL80211_ATTR_AP_SETTINGS_FLAGS) &&
+		    nla_put_u32(msg, NL80211_ATTR_AP_SETTINGS_FLAGS, flags))
 			goto fail;
 	}
 
@@ -5323,7 +5324,8 @@ static int wpa_driver_nl80211_set_ap(void *priv,
 	if (params->freq && nl80211_put_freq_params(msg, params->freq) < 0)
 		goto fail;
 
-	if (params->freq && params->freq->he_enabled) {
+	if (params->freq && params->freq->he_enabled &&
+	    nl80211_attr_supported(drv, NL80211_ATTR_HE_BSS_COLOR)) {
 		struct nlattr *bss_color;
 
 		bss_color = nla_nest_start(msg, NL80211_ATTR_HE_BSS_COLOR);
diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
index 315b88b01a..ccfc98ec33 100644
--- a/src/drivers/driver_nl80211.h
+++ b/src/drivers/driver_nl80211.h
@@ -375,6 +375,11 @@ int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
 #endif /* ANDROID_P2P */
 #endif /* ANDROID */
 
+static inline bool
+nl80211_attr_supported(struct wpa_driver_nl80211_data *drv, int attr)
+{
+	return attr <= drv->global->nl80211_maxattr;
+}
 
 /* driver_nl80211_scan.c */
 
-- 
2.43.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux