1: f234d9d1b0a2 < -: ------------ wifi: nxpwifi: cancel channel switch work on teardown -: ------------ > 1: e7f20d97c95e wifi: nxpwifi: cancel channel switch work on teardown 2: c8b0806fb7d4 ! 2: 35f3100d0a45 wifi: nxpwifi: stop AP TX after preparing channel switch @@ Metadata ## Commit message ## wifi: nxpwifi: stop AP TX after preparing channel switch  - A channel-switch request can leave AP traffic stopped if installing the - CSA management IEs fails or the driver's work wrapper refuses the request. - The driver disables carrier and the TX queues before programming the IEs, - and the wrapper silently drops work during removal, command timeout or - suspend. + A channel switch with block_tx set disables the carrier and TX queues + before the CSA management IEs are installed. If installing them fails, + the request is rejected but TX stays stopped.  - Prepare the CSA IEs before stopping traffic. Queue the switch directly - with wiphy_delayed_work_queue(), since the driver's wrapper can silently - discard it after the IEs are installed and traffic is stopped. The wiphy - mutex serializes the callback and worker with AP-stop cancellation. + Stop TX only after the IEs are installed.  - LLM assistance was used to find the bug and review. + Found by code review. Compile-tested with W=1.  Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x") Cc: stable@vger.kernel.org @@ drivers/net/wireless/nxp/nxpwifi/cfg80211.c: nxpwifi_cfg80211_channel_switch(str  + chsw_msec = max(params->count * priv->bss_cfg.beacon_period, 100);  -- nxpwifi_queue_delayed_wiphy_work(priv->adapter, -- &priv->dfs_chan_sw_work, -- msecs_to_jiffies(chsw_msec)); -+ wiphy_delayed_work_queue(wiphy, &priv->dfs_chan_sw_work, -+ msecs_to_jiffies(chsw_msec)); -  - done: - return ret; + nxpwifi_queue_delayed_wiphy_work(priv->adapter, 3: ac99420cc676 ! 3: 0e1214d7e7c8 wifi: nxpwifi: own beacon data used by channel switch work @@ Metadata ## Commit message ## wifi: nxpwifi: own beacon data used by channel switch work  - Channel-switch work passes beacon data to nxpwifi_set_mgmt_ies() after - the cfg80211 callback returns, but the driver retains only a shallow copy - of pointers into the request. The request storage can be freed before the - delayed work runs. + The channel-switch work reads the new beacon data after the cfg80211 + callback has returned, but the driver keeps only pointers into the + request, which can be freed by then. The IE parser then reads freed + memory.  - The IE parser can then read freed memory. Stale bytes that pass its - element checks can be copied into management-IE commands sent to firmware. + Copy the beacon buffers used by nxpwifi_set_mgmt_ies() into an owned + cfg80211_ap_update. Free it when the work finishes or is canceled, and + return -EBUSY while a switch is pending.  - Deep-copy the four beacon buffers consumed by nxpwifi_set_mgmt_ies() into - an owned cfg80211_ap_update. Keep the existing change_beacon path, reject - overlapping switches while the update is owned, and release it when the - work finishes or is canceled. - - LLM assistance was used to find the bug and review. + Found by code review. Compile-tested with W=1.  Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x") - Cc: # needs a smaller backport + Cc: stable@vger.kernel.org Signed-off-by: Zhao Li   ## drivers/net/wireless/nxp/nxpwifi/11h.c ## @@ drivers/net/wireless/nxp/nxpwifi/11h.c: void nxpwifi_dfs_chan_sw_work(struct wip  ## drivers/net/wireless/nxp/nxpwifi/cfg80211.c ##  @@ drivers/net/wireless/nxp/nxpwifi/cfg80211.c: static int nxpwifi_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, - int ret;  wiphy_delayed_work_cancel(wiphy, &priv->dfs_chan_sw_work); + priv->uap_stop_tx = false;  + kfree(priv->ap_update_info);  + priv->ap_update_info = NULL; nxpwifi_abort_cac(priv); @@ drivers/net/wireless/nxp/nxpwifi/cfg80211.c: static int nxpwifi_cfg80211_set_coa  +{  + struct cfg80211_ap_update *update;  + struct cfg80211_beacon_data *copy; ++ size_t len;  + u8 *pos; -+ size_t len = beacon->tail_len + beacon->beacon_ies_len + -+ beacon->proberesp_ies_len + beacon->assocresp_ies_len;  +  + /* Each length comes from a bounded netlink attribute. */ ++ len = beacon->tail_len + beacon->beacon_ies_len + ++ beacon->proberesp_ies_len + beacon->assocresp_ies_len; ++  + update = kzalloc(sizeof(*update) + len, GFP_KERNEL);  + if (!update)  + return NULL; 4: b530ebe2e699 ! 4: 000f122a3d0a wifi: nxpwifi: stop AP when delayed channel switch fails @@ Metadata ## Commit message ## wifi: nxpwifi: stop AP when delayed channel switch fails  - A delayed AP channel switch can fail while stopping the BSS, programming - the new beacon, or restarting the AP. The worker returns without notifying - cfg80211, and traffic can remain enabled over a stopped BSS when the - request did not set block_tx. + The delayed channel-switch work can fail while stopping the BSS, setting + the beacon or restarting the AP. It then returns without telling + cfg80211, and TX stays enabled over the stopped BSS unless the request + set block_tx.  - An earlier stop failure can also clear the driver's AP configuration while - cfg80211 still considers the AP running. A following channel switch then - reaches the worker without a beacon period and is discarded. + On each failure, stop the carrier and TX queues, clear uap_stop_tx and + request interface shutdown, then free the beacon update as on success.  - Disable carrier and the TX queues, retain the channel-switch state, and - request interface shutdown on all four failures. Keeping the state until - the stop path cancels it prevents another switch from starting while - shutdown is pending. - - LLM assistance was used to find the bug and review. + Found by code review. Compile-tested with W=1.  Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x") - Cc: # depends on the beacon ownership backport + Cc: stable@vger.kernel.org Signed-off-by: Zhao Li   ## drivers/net/wireless/nxp/nxpwifi/11h.c ## @@ drivers/net/wireless/nxp/nxpwifi/11h.c: void nxpwifi_dfs_chan_sw_work(struct wip priv->uap_stop_tx = false; }  --out: - kfree(priv->ap_update_info); - priv->ap_update_info = NULL; -+ return; ++ goto out;  +  +stop_iface:  + netif_carrier_off(priv->netdev);  + nxpwifi_stop_net_dev_queue(priv->netdev, adapter); -+ priv->uap_stop_tx = true; ++ priv->uap_stop_tx = false;  + cfg80211_stop_iface(wiphy, &priv->wdev, GFP_KERNEL); - } + out: + kfree(priv->ap_update_info); + priv->ap_update_info = NULL;