mwifiex: MAC randomization should not be persistent
authorBrian Norris <briannorris@chromium.org>
Wed, 5 Apr 2017 22:26:40 +0000 (15:26 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 20 Apr 2017 07:17:01 +0000 (10:17 +0300)
nl80211 provides the NL80211_SCAN_FLAG_RANDOM_ADDR for every scan
request that should be randomized; the absence of such a flag means we
should not randomize. However, mwifiex was stashing the latest
randomization request and *always* using it for future scans, even those
that didn't set the flag.

Let's zero out the randomization info whenever we get a scan request
without NL80211_SCAN_FLAG_RANDOM_ADDR. I'd prefer to remove
priv->random_mac entirely (and plumb the randomization MAC properly
through the call sequence), but the spaghetti is a little difficult to
unravel here for me.

Fixes: c2a8f0ff9c6c ("mwifiex: support random MAC address for scanning")
Cc: <stable@vger.kernel.org> # 4.9+
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/mwifiex/cfg80211.c

index 44d06177859e75a680c7f100b4c5de47fae89940..4107663130657e358aa4f86fbaa18ca5cff62e20 100644 (file)
@@ -2547,9 +2547,11 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
                        priv->random_mac[i] |= get_random_int() &
                                               ~(request->mac_addr_mask[i]);
                }
+               ether_addr_copy(user_scan_cfg->random_mac, priv->random_mac);
+       } else {
+               eth_zero_addr(priv->random_mac);
        }
 
-       ether_addr_copy(user_scan_cfg->random_mac, priv->random_mac);
        user_scan_cfg->num_ssids = request->n_ssids;
        user_scan_cfg->ssid_list = request->ssids;