linux/drivers/net/wireless
Fedor Pchelkin e9fd43b799 wifi: rtw89: avoid possible TX wait initialization race
[ Upstream commit c24248ed78 ]

The value of skb_data->wait indicates whether skb is passed on to the
core mac80211 stack or released by the driver itself.  Make sure that by
the time skb is added to txwd queue and becomes visible to the completing
side, it has already allocated and initialized TX wait related data (in
case it's needed).

This is found by code review and addresses a possible race scenario
described below:

      Waiting thread                          Completing thread

rtw89_core_send_nullfunc()
  rtw89_core_tx_write_link()
    ...
    rtw89_pci_txwd_submit()
      skb_data->wait = NULL
      /* add skb to the queue */
      skb_queue_tail(&txwd->queue, skb)

  /* another thread (e.g. rtw89_ops_tx) performs TX kick off for the same queue */

                                            rtw89_pci_napi_poll()
                                            ...
                                              rtw89_pci_release_txwd_skb()
                                                /* get skb from the queue */
                                                skb_unlink(skb, &txwd->queue)
                                                rtw89_pci_tx_status()
                                                  rtw89_core_tx_wait_complete()
                                                  /* use incorrect skb_data->wait */
  rtw89_core_tx_kick_off_and_wait()
  /* assign skb_data->wait but too late */

Found by Linux Verification Center (linuxtesting.org).

Fixes: 1ae5ca6152 ("wifi: rtw89: add function to wait for completion of TX skbs")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250919210852.823912-3-pchelkin@ispras.ru
[ adapted rtw89_core_tx_write_link() modifications to rtw89_core_tx_write() ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-23 16:20:41 +02:00
..
admtek wifi: mac80211: inform the low level if drv_stop() is a suspend 2024-06-26 10:25:46 +02:00
ath wifi: ath11k: HAL SRNG: don't deinitialize and re-initialize again 2025-10-19 16:33:58 +02:00
atmel wifi: at76c50x: fix use after free access in at76_disconnect 2025-04-25 10:47:37 +02:00
broadcom wifi: brcmfmac: fix use-after-free when rescheduling brcmf_btcoex_info work 2025-09-09 18:58:06 +02:00
intel wifi: iwlwifi: Remove redundant header files 2025-10-15 12:00:09 +02:00
intersil wifi: p54: prevent buffer-overflow in p54_rx_eeprom_readback() 2025-06-27 11:11:14 +01:00
marvell wifi: mwifiex: send world regulatory domain to driver 2025-10-15 12:00:08 +02:00
mediatek wifi: mt76: mt7921u: Add VID/PID for Netgear A7500 2025-10-19 16:33:58 +02:00
microchip wifi: wilc1000: avoid buffer overflow in WID string configuration 2025-09-25 11:13:41 +02:00
purelifi wifi: plfxlc: Fix error handling in usb driver probe 2025-08-15 12:13:45 +02:00
quantenna wifi: cfg80211: handle DFS per link 2024-09-06 13:01:05 +02:00
ralink wifi: rt2x00: fix remove callback type mismatch 2025-07-17 18:37:17 +02:00
realtek wifi: rtw89: avoid possible TX wait initialization race 2025-10-23 16:20:41 +02:00
rsi wifi: rsi: Remove an unused field in struct rsi_debugfs 2024-09-09 15:30:49 +03:00
silabs wifi: wfx: Fix error handling in wfx_core_init() 2024-12-05 14:01:51 +01:00
st wifi: cw1200: cap SSID length in cw1200_do_join() 2025-09-09 18:58:12 +02:00
ti wifi: wl1251: fix memory leak in wl1251_tx_work 2025-04-25 10:47:37 +02:00
virtual wifi: virt_wifi: Fix page fault on connect 2025-10-02 13:44:08 +02:00
zydas wifi: zd1211rw: Fix potential NULL pointer dereference in zd_mac_tx_to_dev() 2025-07-17 18:37:16 +02:00
Kconfig wifi: remove orphaned rndis_wlan driver 2023-10-30 19:30:33 +02:00
Makefile wifi: remove orphaned rndis_wlan driver 2023-10-30 19:30:33 +02:00