[PATCH 2/2] nl80211: Avoid sending unsupported attributes
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Dec 28 05:14:06 PST 2023
From: Benjamin Berg <benjamin.berg at intel.com>
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 at intel.com>
---
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
More information about the Hostap
mailing list