From: Ping-Ke Shih <pkshih@realtek.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>,
Zong-Zhe Yang <kevin_yang@realtek.com>
Cc: Bitterblue Smith <rtl8821cerfe2@gmail.com>,
Bernie Huang <phhuang@realtek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH rtw v4 2/4] wifi: rtw89: fix tx_wait initialization race
Date: Thu, 18 Sep 2025 05:47:37 +0000 [thread overview]
Message-ID: <08b25263c6874a089e4a271cb95a9cb7@realtek.com> (raw)
In-Reply-To: <20250917095302.2908617-3-pchelkin@ispras.ru>
Fedor Pchelkin <pchelkin@ispras.ru> wrote:
> Now that nullfunc skbs are recycled in a separate work item in the driver,
> the following race during initialization and processing of those skbs
> might lead to noticeable bugs:
>
> 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)
> 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 */
How will we receive tx completion before TX kick off?
(see the original code below)
[...]
> diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
> index 438930b65631..1efe4bb09262 100644
> --- a/drivers/net/wireless/realtek/rtw89/core.c
> +++ b/drivers/net/wireless/realtek/rtw89/core.c
> @@ -1094,22 +1094,13 @@ int rtw89_core_tx_kick_off_and_wait(struct rtw89_dev *rtwdev, struct sk_buff *sk
> int qsel, unsigned int timeout)
> {
> struct rtw89_tx_skb_data *skb_data = RTW89_TX_SKB_CB(skb);
> - struct rtw89_tx_wait_info *wait;
> + struct rtw89_tx_wait_info *wait = wiphy_dereference(rtwdev->hw->wiphy,
> + skb_data->wait);
Can't we just pass 'wait' by function argument?
> unsigned long time_left;
> int ret = 0;
>
> lockdep_assert_wiphy(rtwdev->hw->wiphy);
>
> - wait = kzalloc(sizeof(*wait), GFP_KERNEL);
> - if (!wait) {
> - rtw89_core_tx_kick_off(rtwdev, qsel);
> - return 0;
> - }
> -
> - init_completion(&wait->completion);
> - wait->skb = skb;
> - rcu_assign_pointer(skb_data->wait, wait);
> -
Here, original code prepares completion before TX kick off. How it could
be a problem? Do I miss something?
> rtw89_core_tx_kick_off(rtwdev, qsel);
> time_left = wait_for_completion_timeout(&wait->completion,
> msecs_to_jiffies(timeout));
next prev parent reply other threads:[~2025-09-18 5:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 9:52 [PATCH rtw v4 0/4] wifi: fixes for rtw89 Fedor Pchelkin
2025-09-17 9:52 ` [PATCH rtw v4 1/4] wifi: rtw89: fix use-after-free in rtw89_core_tx_kick_off_and_wait() Fedor Pchelkin
2025-09-18 4:00 ` Ping-Ke Shih
2025-09-18 4:40 ` Zong-Zhe Yang
2025-09-18 5:23 ` Ping-Ke Shih
2025-09-18 13:34 ` Fedor Pchelkin
2025-09-19 0:27 ` Ping-Ke Shih
2025-09-17 9:52 ` [PATCH rtw v4 2/4] wifi: rtw89: fix tx_wait initialization race Fedor Pchelkin
2025-09-18 5:47 ` Ping-Ke Shih [this message]
2025-09-18 15:19 ` Fedor Pchelkin
2025-09-19 0:34 ` Ping-Ke Shih
2025-09-19 0:50 ` Ping-Ke Shih
2025-09-19 7:46 ` Fedor Pchelkin
2025-09-17 9:52 ` [PATCH rtw v4 3/4] wifi: rtw89: fix leak in rtw89_core_send_nullfunc() Fedor Pchelkin
2025-09-18 5:48 ` Ping-Ke Shih
2025-09-17 9:52 ` [PATCH rtw v4 4/4] wifi: rtw89: avoid circular locking dependency in ser_state_run() Fedor Pchelkin
2025-09-18 5:52 ` Ping-Ke Shih
2025-09-18 15:30 ` Fedor Pchelkin
2025-09-19 0:46 ` Ping-Ke Shih
2025-09-19 11:00 ` Fedor Pchelkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08b25263c6874a089e4a271cb95a9cb7@realtek.com \
--to=pkshih@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=pchelkin@ispras.ru \
--cc=phhuang@realtek.com \
--cc=rtl8821cerfe2@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox