linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: Felix Fietkau <nbd@openwrt.org>,
	linux-wireless@vger.kernel.org, karl.beldan@gmail.com
Subject: Re: [PATCH] mac80211: fix spurious use of rcu_dereference
Date: Tue, 23 Apr 2013 08:48:28 +0200	[thread overview]
Message-ID: <1366699708.8385.1.camel@jlt4.sipsolutions.net> (raw)
In-Reply-To: <201304230258.08359.chunkeey@googlemail.com> (sfid-20130423_025828_450785_53ED9197)

On Tue, 2013-04-23 at 02:58 +0200, Christian Lamparter wrote:
> This patch fixes the following RCU debug splat:
> 
> ===============================
> [ INFO: suspicious RCU usage. ]
> 3.9.0-rc8-wl+ #31 Tainted: G           O
> -------------------------------
> net/mac80211/rate.c:691 suspicious rcu_dereference_check() usage!
> 
> other info that might help us debug this:
>  
> rcu_scheduler_active = 1, debug_locks = 1
>  3 locks held by hostapd/9451:
>  #0:  (genl_mutex){+.+.+.}, at: [<c1326365>] genl_lock+0xf/0x11
>  #1:  (rtnl_mutex){+.+.+.}, at: [<c13133c4>] rtnl_lock+0xf/0x11
>  #2:  (&rdev->mtx){+.+.+.}, at: [<f853395e>] nl80211_pre_doit+0x166/0x180 [cfg80211]
> 
> stack backtrace:
> Pid: 9451, comm: hostapd Tainted: G           O 3.9.0-rc8-wl+ #31
> Call Trace:
>  [<c107da0b>] lockdep_rcu_suspicious+0xe6/0xee
>  [<f8bf82ad>] rate_control_set_rates+0x43/0x5a [mac80211]
>  [<f8c2cacb>] minstrel_update_rates+0xdc/0xe2 [mac80211]
>  [<f8c2cfb0>] minstrel_rate_init+0x24c/0x33d [mac80211]
>  [<f8c2d9d3>] minstrel_ht_update_caps+0x206/0x234 [mac80211]
>  [<c1080a8d>] ? lock_release+0x1c9/0x226
>  [<f8c2da25>] minstrel_ht_rate_init+0x10/0x14 [mac80211]
>  [...]
> 
> Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
> ---
> Actually, rcu_read_lock() might not be necessary in this special
> case [the RC is not yet initialized, so nothing bad can happen].
> 
> But, since the rcu_read_lock() has a low overhead and
> rate_control_set_rates mac80211.h doc does not mention
> anything about locking, I think this is a viable way. 

I think that, on the contrary, it's completely strange/wrong. ;-)

> +       rcu_read_lock();
> +       old = rcu_dereference(pubsta->rates);

Here's have a dereference.
 
>         rcu_assign_pointer(pubsta->rates, rates);

and here's an assignment. The assignment ought to be protected already
by some locking, presumably, so similarly is the rcu_dereference() which
then should just be rcu_dereference_protected()?

johannes



  reply	other threads:[~2013-04-23  6:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 14:14 [PATCH v6 1/3] mac80211: improve the rate control API Felix Fietkau
2013-04-22 14:14 ` [PATCH v6 2/3] mac80211/minstrel_ht: use the new " Felix Fietkau
2015-02-20 14:12   ` Sven Eckelmann
2015-02-25  9:35     ` Sven Eckelmann
2013-04-22 14:14 ` [PATCH v6 3/3] mac80211/minstrel: " Felix Fietkau
2013-04-22 14:18 ` [PATCH v6 1/3] mac80211: improve the " Johannes Berg
2013-04-22 15:51   ` Karl Beldan
2013-04-23  0:58 ` [PATCH] mac80211: fix spurious use of rcu_dereference Christian Lamparter
2013-04-23  6:48   ` Johannes Berg [this message]
2013-04-23 13:26     ` Christian Lamparter
2013-04-24 11:23       ` Johannes Berg

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=1366699708.8385.1.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=chunkeey@googlemail.com \
    --cc=karl.beldan@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@openwrt.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;
as well as URLs for NNTP newsgroup(s).