hostapd: build HT and VHT operation of a BSS without hardware modes

Patch 170 reads hapd->iface->current_mode->vht_capab in
hostapd_eid_ht_operation() and hostapd_eid_vht_operation() without a
check of current_mode. A BSS of driver=none has no hardware modes, so
current_mode stays NULL, and hostapd crashes at the start of such a BSS
with ieee80211n=1 or ieee80211ac=1:

  WPA_TRACE: eloop SIGSEGV - START
  hostapd_eid_ht_operation() ../src/ap/ieee802_11_ht.c:150
  ieee802_11_build_ap_params() ../src/ap/beacon.c:2427
  hostapd_setup_bss() ../src/ap/hostapd.c:2566

Take the extended NSS BW capability only from a present mode, like
hostapd_eid_vht_capabilities() already does.

Fixes: adfeda8491 ("hostapd: add fix for dealing with VHT 160 MHz via ext nss bw")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau committed 2026-10-28 14:46:20 +00:00
1 parent 4f88e1b6d4
commit 908ed08613
2 files changed
+11 -20

No files matched your search

@@ -21,11 +21,11 @@ operation information element instead.
Signed-off-by: P Praneesh <ppranees@codeaurora.org>
---
hostapd/config_file.c | 2 ++
src/ap/ieee802_11_ht.c | 9 +++++++++
src/ap/ieee802_11_vht.c | 17 +++++++++++++++++
src/ap/ieee802_11_ht.c | 8 ++++++++
src/ap/ieee802_11_vht.c | 16 ++++++++++++++++
src/common/hw_features_common.c | 1 +
src/common/ieee802_11_defs.h | 2 ++
5 files changed, 31 insertions(+)
5 files changed, 29 insertions(+)
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -44,19 +44,18 @@ Signed-off-by: P Praneesh <ppranees@codeaurora.org>
u8 * hostapd_eid_ht_operation(struct hostapd_data *hapd, u8 *eid)
{
struct ieee80211_ht_operation *oper;
+ le32 vht_capabilities_info;
+ struct hostapd_hw_modes *mode = hapd->iface->current_mode;
u8 *pos = eid;
+ u8 chwidth;
if (!hostapd_is_ht_enabled(hapd) ||
is_6ghz_op_class(hapd->iconf->op_class))
@@ -143,6 +145,13 @@ u8 * hostapd_eid_ht_operation(struct hos
@@ -143,6 +145,12 @@ u8 * hostapd_eid_ht_operation(struct hos
oper->operation_mode = host_to_le16(hapd->iface->ht_op_mode);
set_ht_param(hapd, oper);
+ vht_capabilities_info = host_to_le32(hapd->iface->current_mode->vht_capab);
+ chwidth = hostapd_get_oper_chwidth(hapd->iconf);
+ if (vht_capabilities_info & VHT_CAP_EXTENDED_NSS_BW_SUPPORT
+ if (mode && (mode->vht_capab & VHT_CAP_EXTENDED_NSS_BW_SUPPORT)
+ && ((chwidth == CHANWIDTH_160MHZ) || (chwidth == CHANWIDTH_80P80MHZ))) {
+ oper->operation_mode = host_to_le16(hapd->iconf->vht_oper_centr_freq_seg0_idx << 5);
+ }
@@ -96,24 +95,16 @@ Signed-off-by: P Praneesh <ppranees@codeaurora.org>
u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid)
{
struct ieee80211_vht_operation *oper;
+ le32 vht_capabilities_info;
+ struct hostapd_hw_modes *mode = hapd->iface->current_mode;
u8 *pos = eid;
enum oper_chan_width oper_chwidth =
hostapd_get_oper_chwidth(hapd->iconf);
@@ -120,6 +133,7 @@ u8 * hostapd_eid_vht_operation(struct ho
oper->vht_op_info_chan_center_freq_seg1_idx = seg1;
oper->vht_op_info_chwidth = oper_chwidth;
+ vht_capabilities_info = host_to_le32(hapd->iface->current_mode->vht_capab);
if (oper_chwidth == CONF_OPER_CHWIDTH_160MHZ) {
/*
* Convert 160 MHz channel width to new style as interop
@@ -133,6 +147,9 @@ u8 * hostapd_eid_vht_operation(struct ho
@@ -133,6 +146,9 @@ u8 * hostapd_eid_vht_operation(struct ho
oper->vht_op_info_chan_center_freq_seg0_idx -= 8;
else
oper->vht_op_info_chan_center_freq_seg0_idx += 8;
+
+ if (vht_capabilities_info & VHT_CAP_EXTENDED_NSS_BW_SUPPORT)
+ if (mode && (mode->vht_capab & VHT_CAP_EXTENDED_NSS_BW_SUPPORT))
+ oper->vht_op_info_chan_center_freq_seg1_idx = 0;
} else if (oper_chwidth == CONF_OPER_CHWIDTH_80P80MHZ) {
/*
@@ -41,7 +41,7 @@ Subject: [PATCH] Add noscan, no_ht_coex config options
hostapd_set_state(iface, HAPD_IFACE_HT_SCAN);
--- a/src/ap/ieee802_11_ht.c
+++ b/src/ap/ieee802_11_ht.c
@@ -279,6 +279,9 @@ void hostapd_2040_coex_action(struct hos
@@ -278,6 +278,9 @@ void hostapd_2040_coex_action(struct hos
return;
}
@@ -51,7 +51,7 @@ Subject: [PATCH] Add noscan, no_ht_coex config options
if (len < IEEE80211_HDRLEN + 2 + sizeof(*bc_ie)) {
wpa_printf(MSG_DEBUG,
"Ignore too short 20/40 BSS Coexistence Management frame");
@@ -439,6 +442,9 @@ void ht40_intolerant_add(struct hostapd_
@@ -438,6 +441,9 @@ void ht40_intolerant_add(struct hostapd_
if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
return;