Re: [PATCH] mac80211: fix race in ieee80211_register_hw()

From: Kalle Valo
Date: Mon Apr 06 2020 - 09:27:28 EST


Sumit Garg <sumit.garg@xxxxxxxxxx> writes:

> On Mon, 6 Apr 2020 at 18:38, Johannes Berg <johannes@xxxxxxxxxxxxxxxx> wrote:
>>
>> On Mon, 2020-04-06 at 16:04 +0300, Kalle Valo wrote:
>> > Johannes Berg <johannes@xxxxxxxxxxxxxxxx> writes:
>> >
>> > > On Mon, 2020-04-06 at 15:52 +0300, Kalle Valo wrote:
>> > > > Johannes Berg <johannes@xxxxxxxxxxxxxxxx> writes:
>> > > >
>> > > > > On Mon, 2020-04-06 at 15:44 +0300, Kalle Valo wrote:
>> > > > > > > user-space ieee80211_register_hw() RX IRQ
>> > > > > > > +++++++++++++++++++++++++++++++++++++++++++++
>> > > > > > > | | |
>> > > > > > > |<---wlan0---wiphy_register() |
>> > > > > > > |----start wlan0---->| |
>> > > > > > > | |<---IRQ---(RX packet)
>> > > > > > > | Kernel crash |
>> > > > > > > | due to unallocated |
>> > > > > > > | workqueue. |
>> > > > >
>> > > > > [snip]
>> > > > >
>> > > > > > I have understood that no frames should be received until mac80211 calls
>> > > > > > struct ieee80211_ops::start:
>> > > > > >
>> > > > > > * @start: Called before the first netdevice attached to the hardware
>> > > > > > * is enabled. This should turn on the hardware and must turn on
>> > > > > > * frame reception (for possibly enabled monitor interfaces.)
>> > > > >
>> > > > > True, but I think he's saying that you can actually add and configure an
>> > > > > interface as soon as the wiphy is registered?
>> > > >
>> > > > With '<---IRQ---(RX packet)' I assumed wcn36xx is delivering a frame to
>> > > > mac80211 using ieee80211_rx(), but of course I'm just guessing here.
>> > >
>> > > Yeah, but that could be legitimate?
>> >
>> > Ah, I misunderstood then. The way I have understood is that no rx frames
>> > should be delivered (= calling ieee80211_rx()_ before start() is called,
>> > but if that's not the case please ignore me :)
>>
>> No no, that _is_ the case. But I think the "start wlan0" could end up
>> calling it?
>>
>
> Sorry if I wasn't clear enough via the sequence diagram. It's a common
> RX packet that arrives via ieee80211_tasklet_handler() which is
> enabled via call to "struct ieee80211_ops::start" api.

Ah sorry, I didn't realise that. So wcn36xx is not to be blamed then,
thanks for the clarification.

--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches