* [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop()
@ 2022-02-07 15:31 Jia-Ju Bai
2022-02-07 21:13 ` Christian Lamparter
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2022-02-07 15:31 UTC (permalink / raw)
To: chunkeey, kvalo, davem, kuba; +Cc: linux-wireless, netdev, linux-kernel
Hello,
My static analysis tool reports a possible deadlock in the p54 driver in
Linux 5.16:
p54_remove_interface()
mutex_lock(&priv->conf_mutex); --> Line 262 (Lock A)
wait_for_completion_interruptible_timeout(&priv->beacon_comp, HZ); -->
Line 271 (Wait X)
p54_stop()
mutex_lock(&priv->conf_mutex); --> Line 208 (Lock A)
p54p_stop() (call via priv->stop)
p54_free_skb()
p54_tx_qos_accounting_free()
complete(&priv->beacon_comp); --> Line 230 (Wake X)
When p54_remove_interface() is executed, "Wait X" is performed by
holding "Lock A". If p54_stop() is executed at this time, "Wake X"
cannot be performed to wake up "Wait X" in p54_remove_interface(),
because "Lock A" has been already hold by p54_remove_interface(),
causing a possible deadlock.
I find that "Wait X" is performed with a timeout, to relieve the
possible deadlock; but I think this timeout can cause inefficient execution.
I am not quite sure whether this possible problem is real and how to fix
it if it is real.
Any feedback would be appreciated, thanks :)
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop()
2022-02-07 15:31 [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop() Jia-Ju Bai
@ 2022-02-07 21:13 ` Christian Lamparter
0 siblings, 0 replies; 2+ messages in thread
From: Christian Lamparter @ 2022-02-07 21:13 UTC (permalink / raw)
To: Jia-Ju Bai, chunkeey, kvalo, davem, kuba
Cc: linux-wireless, netdev, linux-kernel
Hi,
On 07/02/2022 16:31, Jia-Ju Bai wrote:
> Hello,
>
> My static analysis tool reports a possible deadlock in the p54 driver in Linux 5.16:
>
> p54_remove_interface()
> mutex_lock(&priv->conf_mutex); --> Line 262 (Lock A)
> wait_for_completion_interruptible_timeout(&priv->beacon_comp, HZ); --> Line 271 (Wait X)
>
> p54_stop()
> mutex_lock(&priv->conf_mutex); --> Line 208 (Lock A)
> p54p_stop() (call via priv->stop)
> p54_free_skb()
> p54_tx_qos_accounting_free()
> complete(&priv->beacon_comp); --> Line 230 (Wake X)
>
> When p54_remove_interface() is executed, "Wait X" is performed by holding "Lock A".
> If p54_stop() is executed at this time, "Wake X" cannot be performed to wake
> up "Wait X" in p54_remove_interface(), because "Lock A" has been already hold by
> p54_remove_interface(), causing a possible deadlock.
>
> I find that "Wait X" is performed with a timeout, to relieve the possible deadlock;
> but I think this timeout can cause inefficient execution.
>
> I am not quite sure whether this possible problem is real and how to fix it if it is real.
> Any feedback would be appreciated, thanks :)
This has been such a long long time ago. But I think I found
the right documentation entry for you:
<https://www.kernel.org/doc/html/v5.16/driver-api/80211/mac80211.html> (scroll down a bit)
| remove_interface
| Notifies a driver that an interface is going down.
| >>The stop callback is called after this if it is the last interface
| and no monitor interfaces are present.<<
| (it goes on a bit. But I don't think there's anything important left)
The documentation tells you not to worry. p54_stop() and p54_remove_interface()
are being serialized by mac80211.
Cheers,
Christian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-07 21:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 15:31 [BUG] intersil: p54: possible deadlock in p54_remove_interface() and p54_stop() Jia-Ju Bai
2022-02-07 21:13 ` Christian Lamparter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.