RE: [PATCH rtw-next v5 06/10] wifi: rtw89: transmit frames from monitor interfaces
From: Ping-Ke Shih
Date: Sun Nov 15 2026 - 20:36:00 EST
Enver Ikromov <owner@xxxxxxxxxxxxxx> wrote:
> Frames injected on a monitor interface reach the driver either through
> rtw89_ops_tx() (with info->control.vif == NULL for a passive monitor,
> info->control.vif == &sdata->vif for MONITOR_FLAG_ACTIVE, or a running
> interface matched by addr2) or,
What do you want to do in this patch? Flag MONITOR_FLAG_ACTIVE, so rtw89
can handle the ACKs?
> for injected data frames whose addr2
> matches an active interface, via wake_tx_queue and
> rtw89_core_txq_push().
How can I reproduce this? I setup wlan0 + mon0 (with UP state), and
use your script to inject packet with wlan0's mac address, it still
goes via rtw89_ops_tx().
>
> Passing local->monitor_sdata directly is racy because
> ieee80211_del_virtual_monitor() calls drv_remove_interface() before
> clearing local->monitor_sdata, so mac80211 may still pass a tearing-down
> monitor vif to rtw89_ops_tx() after the driver has released its MAC ID
> and port.
The local->monitor_sdata is RCU data, and ieee80211_monitor_start_xmit()
holds rcu_read_lock(). Is it a problematic?
>
> In rtw89_ops_tx(), require an active PHY entity and resolve passive
> monitor TX through rtwdev->pure_monitor_mode_vif under rcu_read_lock(),
> while permitting concurrent MONITOR_FLAG_ACTIVE interfaces to transmit
> through their own driver vif while rtwvif->mon_tx_ready is set (clearing
> mon_tx_ready and coalescing synchronize_rcu() before teardown). Track
> active driver monitor vifs in rtwdev->monitor_vifs via
> rtw89_is_monitoring() so concurrent MONITOR_FLAG_ACTIVE interfaces
> reserve radiotap headroom and enable PHY status parsing (parsing scan
> channel IEs before pushing radiotap headers), and verify skb_headlen()
> in rtw89_core_tx_write_link() before reading skb->data.
I don't think rtwdev->monitor_vifs can be more than one. How could it
be?
>
> Signed-off-by: Enver Ikromov <owner@xxxxxxxxxxxxxx>
> ---
> drivers/net/wireless/realtek/rtw89/core.c | 22 ++++--
> drivers/net/wireless/realtek/rtw89/core.h | 10 ++-
> drivers/net/wireless/realtek/rtw89/mac80211.c | 71 ++++++++++++++++---
> drivers/net/wireless/realtek/rtw89/phy.c | 2 +-
> 4 files changed, 88 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
> index 9cf2b03..54605f7 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -1450,6 +1450,14 @@ static int rtw89_core_tx_write_link(struct rtw89_dev *rtwdev,
> struct rtw89_core_tx_request tx_req = {};
> int ret;
>
> + if (unlikely(IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_INJECTED)) {
> + struct ieee80211_hdr *hdr = (void *)skb->data;
> +
> + if (skb_headlen(skb) < sizeof(struct ieee80211_cts) ||
> + skb_headlen(skb) < ieee80211_hdrlen(hdr->frame_control))
> + return -EINVAL;
> + }
> +
If validation is necessary, should you validate more? not only CTS?
Also, create a function to do this. I feel only rtw89_ops_tx() can be entry of
injection, please do validation there.
> tx_req.skb = skb;
> tx_req.vif = vif;
> tx_req.sta = sta;
[...]
> @@ -9323,12 +9325,18 @@ static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
> return &fw_info->normal;
> }
>
> +static inline bool rtw89_is_monitoring(struct rtw89_dev *rtwdev)
> +{
> + return (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR) ||
> + READ_ONCE(rtwdev->monitor_vifs);
The monitor_vifs > 1 is not possible, why do you need this?
The flag IEEE80211_CONF_MONITOR is cleared if both wlan0 + mon0 are UP.
Do you actually need that? I have no good idea now. Can we just focus
on single monitor case? Or just avoid crash from concurrency
combination.