From: Ping-Ke Shih <pkshih@realtek.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>
Cc: Zong-Zhe Yang <kevin_yang@realtek.com>,
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 1/4] wifi: rtw89: fix use-after-free in rtw89_core_tx_kick_off_and_wait()
Date: Fri, 19 Sep 2025 00:27:33 +0000 [thread overview]
Message-ID: <e4153922734d4c8f8b394b3542b9cf58@realtek.com> (raw)
In-Reply-To: <20250918160829-9fbf03ca95d5c4a93143afef-pchelkin@ispras>
Fedor Pchelkin <pchelkin@ispras.ru> wrote:
> On Thu, 18. Sep 05:23, Ping-Ke Shih wrote:
> > Zong-Zhe Yang <kevin_yang@realtek.com> wrote:
> > > Ping-Ke Shih <pkshih@realtek.com> wrote:
> > > >
> > > > Fedor Pchelkin <pchelkin@ispras.ru> wrote:
> > > >
> > > > [...]
> > > >
> > > > > @@ -6181,6 +6187,27 @@ rtw89_assoc_link_rcu_dereference(struct rtw89_dev *rtwdev,
> > > > u8 macid)
> > > > > list_first_entry_or_null(&p->dlink_pool,
> > > > > typeof(*p->links_inst), dlink_schd); \
> > > > > })
> > > > >
> > > > > +static inline void rtw89_tx_wait_release(struct rtw89_tx_wait_info
> > > > > +*wait) {
> > > > > + dev_kfree_skb_any(wait->skb);
> > > > > + kfree_rcu(wait, rcu_head);
> > > > > +}
> > > > > +
> > > > > +static inline void rtw89_tx_wait_list_clear(struct rtw89_dev *rtwdev)
> > > > > +{
> > > > > + struct rtw89_tx_wait_info *wait, *tmp;
> > > > > +
> > > > > + lockdep_assert_wiphy(rtwdev->hw->wiphy);
> > > > > +
> > > > > + list_for_each_entry_safe(wait, tmp, &rtwdev->tx_waits, list) {
> > > > > + if (!wait_for_completion_timeout(&wait->completion,
> > > > > +
> > > > RTW89_TX_WAIT_DEFAULT_TIMEOUT))
> > > > > + continue;
> > > >
> > > >
> > > > Why should we wait 10ms? Just try_wait_for_completion()?
> > > >
> > > > Since TX completion might be missing (rtw89_core_stop(), for example), shouldn't we
> > > > unconditionally free all in wait list for that case?
> > > >
> > >
> > > In hci reset (when we release pending skb), the condition will become true.
> > > So, all left will be freed at that time. Before that, there is no logic to ensure no
> > > more completing side, so it cannot be unconditionally freed unless we don't
> > > want to double check if those, which timed out, are done at some moment.
> > >
> > > (e.g. core stop will do hci reset)
> >
> > Thanks for the explanation.
> >
> > Just consider try_wait_for_completion() then.
>
> OK. completion_done() looks appropriate here as well.
>
> >
> > By the way, if want a delay for timeout case, use delayed work for tx_wait_work
> > instead.
>
> That makes sense, thanks. So the next time I'll go with delayed
> tx_wait_work performing completion_done(): work delay 500 ms, looks
> neither too small nor too big for freeing potentially timed out items.
Both look reasonable to me.
next prev parent reply other threads:[~2025-09-19 0:27 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 [this message]
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
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=e4153922734d4c8f8b394b3542b9cf58@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