linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aloka Dixit <alokad@codeaurora.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v11 1/4] nl80211: MBSSID and EMA support in AP mode
Date: Tue, 14 Sep 2021 21:00:27 -0700	[thread overview]
Message-ID: <a1d3ea130c11902bd772535eadd0ef47@codeaurora.org> (raw)
In-Reply-To: <46cbed48d41a7200cec3d7428abe7bc6746e14fe.camel@sipsolutions.net>

On 2021-08-17 03:33, Johannes Berg wrote:
> Hi,
> 
> I don't know if this issue was already present before, but it's
> certainly due to the locking changes I had made with the RTNL some time
> ago...
> 
>> +static int nl80211_parse_mbssid_config(struct wiphy *wiphy,
>> +				       struct net_device *dev,
>> +				       struct nlattr *attrs,
>> +				       struct cfg80211_mbssid_config *config,
>> +				       u8 num_elems)
>> +{
>> +	struct nlattr *tb[NL80211_MBSSID_CONFIG_ATTR_MAX + 1];
>> +	struct net_device *tx_dev = dev;
> 
> Here tx_dev defaults to the dev, that's fine, it might be the
> transmitting interface.
> 
>> +	if (tb[NL80211_MBSSID_CONFIG_ATTR_TRANSMITTING_IFINDEX]) {
>> +		tx_ifindex =
>> +			nla_get_u32(tb[NL80211_MBSSID_CONFIG_ATTR_TRANSMITTING_IFINDEX]);
>> +
>> +		if (!config->index && tx_ifindex != dev->ifindex)
>> +			return -EINVAL;
>> +
>> +		tx_dev = __dev_get_by_index(wiphy_net(wiphy), tx_ifindex);
> 
> Here you try to look up the other transmitting device, and use
> __dev_get_by_index() for that - but we don't hold any relevant lock
> here!
> 
> This is (only) called from nl80211_start_ap(), which doesn't hold the
> RTNL since commit a05829a7222e ("cfg80211: avoid holding the RTNL when
> calling the driver"):
> 
>         {
>                 .cmd = NL80211_CMD_START_AP,
>                 .validate = GENL_DONT_VALIDATE_STRICT | 
> GENL_DONT_VALIDATE_DUMP,
>                 .flags = GENL_UNS_ADMIN_PERM,
>                 .doit = nl80211_start_ap,
> -               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
> -                                 NL80211_FLAG_NEED_RTNL,
> +               .internal_flags = NL80211_FLAG_NEED_NETDEV_UP,
>         },
> 
> 
> I'd fix this, but it's not really trivial - we'd need to use
> dev_get_by_index() and ensure we dev_put() appropriately, but *only* if
> it's different from the original dev ... could probably do that in this
> function.
> 
> All told though this doesn't make me really very confident you tested
> this recently, seems like something would've complained here?
> 

I tested a flavored version, testing without that this time.

Other instances of calls to __dev_get_by_index() which don't already 
hold
RTNL explicitly call rtnl_lock()/unlock().

Is it okay to do same here?

Regarding the reference, I will call dev_hold() before assigning the 
value
to 'tx_dev' pointer if different than the current net_device,
and dev_put() after the processing is done.

Thanks.

  reply	other threads:[~2021-09-15  4:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  7:07 [PATCH v11 0/4] multiple bssid and EMA support in AP mode Aloka Dixit
2021-07-15  7:07 ` [PATCH v11 1/4] nl80211: MBSSID " Aloka Dixit
2021-08-17 10:33   ` Johannes Berg
2021-09-15  4:00     ` Aloka Dixit [this message]
2021-09-15 10:46       ` Johannes Berg
2021-07-15  7:07 ` [PATCH v11 2/4] mac80211: MBSSID support in interface handling Aloka Dixit
2021-07-15  7:07 ` [PATCH v11 3/4] mac80211: MBSSID and EMA support in beacon handling Aloka Dixit
2021-07-15  7:07 ` [PATCH v11 4/4] mac80211: channel switch for non-transmitting interfaces Aloka Dixit
2021-08-17 10:35 ` [PATCH v11 0/4] multiple bssid and EMA support in AP mode Johannes Berg
2021-09-15  3:47   ` Aloka Dixit
2021-09-15 10:47     ` Johannes Berg
2021-09-15 18:47       ` Aloka Dixit

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=a1d3ea130c11902bd772535eadd0ef47@codeaurora.org \
    --to=alokad@codeaurora.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@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;
as well as URLs for NNTP newsgroup(s).