2019-11-21 18:01:36

by Markus Theil

[permalink] [raw]
Subject: [PATCH v8 3/6] mt76: mt76x02: add check for invalid vif idx

On adding vifs the idx can become 1 + (7 & 7) = 8 for APs.
Check against that, as only AP vif idx 0-7 is possible.

Signed-off-by: Markus Theil <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index bdc83838d346..1142aa39a226 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -325,7 +325,9 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
if (vif->type == NL80211_IFTYPE_STATION)
idx += 8;

- if (dev->vif_mask & BIT(idx))
+ /* vif is already set or idx is 8 for AP/Mesh/... */
+ if (dev->vif_mask & BIT(idx) ||
+ vif->type != NL80211_IFTYPE_STATION && idx > 7)
return -EBUSY;

dev->vif_mask |= BIT(idx);
--
2.24.0


2019-11-24 03:32:22

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v8 3/6] mt76: mt76x02: add check for invalid vif idx

Hi Markus,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on next-20191122]
[cannot apply to v5.4-rc8]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Markus-Theil/mt76-channel-switch-support-for-USB-devices/20191124-083548
base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc64

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>

All warnings (new ones prefixed by >>):

drivers/net//wireless/mediatek/mt76/mt76x02_util.c: In function 'mt76x02_add_interface':
>> drivers/net//wireless/mediatek/mt76/mt76x02_util.c:330:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
vif->type != NL80211_IFTYPE_STATION && idx > 7)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

vim +330 drivers/net//wireless/mediatek/mt76/mt76x02_util.c

296
297 int
298 mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
299 {
300 struct mt76x02_dev *dev = hw->priv;
301 unsigned int idx = 0;
302
303 /* Allow to change address in HW if we create first interface. */
304 if (!dev->vif_mask &&
305 (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||
306 memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))
307 mt76x02_mac_setaddr(dev, vif->addr);
308
309 if (vif->addr[0] & BIT(1))
310 idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
311
312 /*
313 * Client mode typically only has one configurable BSSID register,
314 * which is used for bssidx=0. This is linked to the MAC address.
315 * Since mac80211 allows changing interface types, and we cannot
316 * force the use of the primary MAC address for a station mode
317 * interface, we need some other way of configuring a per-interface
318 * remote BSSID.
319 * The hardware provides an AP-Client feature, where bssidx 0-7 are
320 * used for AP mode and bssidx 8-15 for client mode.
321 * We shift the station interface bss index by 8 to force the
322 * hardware to recognize the BSSID.
323 * The resulting bssidx mismatch for unicast frames is ignored by hw.
324 */
325 if (vif->type == NL80211_IFTYPE_STATION)
326 idx += 8;
327
328 /* vif is already set or idx is 8 for AP/Mesh/... */
329 if (dev->vif_mask & BIT(idx) ||
> 330 vif->type != NL80211_IFTYPE_STATION && idx > 7)
331 return -EBUSY;
332
333 dev->vif_mask |= BIT(idx);
334
335 mt76x02_vif_init(dev, vif, idx);
336 return 0;
337 }
338 EXPORT_SYMBOL_GPL(mt76x02_add_interface);
339

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation


Attachments:
(No filename) (3.49 kB)
.config.gz (57.78 kB)
Download all attachments