From: Johannes Berg <johannes@sipsolutions.net>
To: Sumit Garg <sumit.garg@linaro.org>, linux-wireless@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, matthias.schoepfer@ithinx.io,
Philipp.Berg@liebherr.com, Michael.Weitner@liebherr.com,
daniel.thompson@linaro.org, loic.poulain@linaro.org,
stable@vger.kernel.org
Subject: Re: [PATCH] mac80211: fix race in ieee80211_register_hw()
Date: Mon, 06 Apr 2020 14:44:02 +0200 [thread overview]
Message-ID: <f2a393a2f01c93776446c83e345a102a780cfe88.camel@sipsolutions.net> (raw)
In-Reply-To: <1586175677-3061-1-git-send-email-sumit.garg@linaro.org> (sfid-20200406_142251_569735_E1B08414)
On Mon, 2020-04-06 at 17:51 +0530, Sumit Garg wrote:
> A race condition leading to a kernel crash is observed during invocation
> of ieee80211_register_hw() on a dragonboard410c device having wcn36xx
> driver built as a loadable module along with a wifi manager in user-space
> waiting for a wifi device (wlanX) to be active.
>
> Sequence diagram for a particular kernel crash scenario:
>
> user-space ieee80211_register_hw() RX IRQ
> +++++++++++++++++++++++++++++++++++++++++++++
> | | |
> |<---wlan0---wiphy_register() |
> |----start wlan0---->| |
> | |<---IRQ---(RX packet)
> | Kernel crash |
> | due to unallocated |
> | workqueue. |
> | | |
> | alloc_ordered_workqueue() |
> | | |
> | Misc wiphy init. |
> | | |
> | ieee80211_if_add() |
> | | |
>
> As evident from above sequence diagram, this race condition isn't specific
> to a particular wifi driver but rather the initialization sequence in
> ieee80211_register_hw() needs to be fixed.
Indeed, oops.
> So re-order the initialization
> sequence and the updated sequence diagram would look like:
>
> user-space ieee80211_register_hw() RX IRQ
> +++++++++++++++++++++++++++++++++++++++++++++
> | | |
> | alloc_ordered_workqueue() |
> | | |
> | Misc wiphy init. |
> | | |
> |<---wlan0---wiphy_register() |
> |----start wlan0---->| |
> | |<---IRQ---(RX packet)
> | | |
> | ieee80211_if_add() |
> | | |
Makes sense.
> @@ -1254,6 +1250,14 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
> local->sband_allocated |= BIT(band);
> }
>
> + rtnl_unlock();
> +
> + result = wiphy_register(local->hw.wiphy);
> + if (result < 0)
> + goto fail_wiphy_register;
> +
> + rtnl_lock();
I'm a bit worried about this unlock/relock here though.
I think we only need the RTNL for the call to
ieee80211_init_rate_ctrl_alg() and then later ieee80211_if_add(), so
perhaps we can move that a little closer?
All the stuff between is really just setting up local stuff, so doesn't
really need to worry?
johannes
next prev parent reply other threads:[~2020-04-06 12:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-06 12:21 [PATCH] mac80211: fix race in ieee80211_register_hw() Sumit Garg
2020-04-06 12:44 ` Johannes Berg [this message]
2020-04-06 13:00 ` Sumit Garg
2020-04-06 12:44 ` Kalle Valo
2020-04-06 12:47 ` Johannes Berg
2020-04-06 12:52 ` Kalle Valo
2020-04-06 12:53 ` Johannes Berg
2020-04-06 13:04 ` Kalle Valo
2020-04-06 13:07 ` Johannes Berg
2020-04-06 13:21 ` Sumit Garg
2020-04-06 13:27 ` Kalle Valo
2020-04-06 13:55 ` Krishna Chaitanya
2020-04-06 14:01 ` Johannes Berg
2020-04-06 14:25 ` Krishna Chaitanya
2020-04-06 15:06 ` Johannes Berg
2020-04-06 18:08 ` Krishna Chaitanya
2020-04-07 6:42 ` Sumit Garg
2020-04-06 13:06 ` Sumit Garg
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=f2a393a2f01c93776446c83e345a102a780cfe88.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=Michael.Weitner@liebherr.com \
--cc=Philipp.Berg@liebherr.com \
--cc=daniel.thompson@linaro.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=loic.poulain@linaro.org \
--cc=matthias.schoepfer@ithinx.io \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sumit.garg@linaro.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 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.