lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 Jan 2022 18:32:47 +0100
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Alexander Aring <alex.aring@...il.com>,
        Stefan Schmidt <stefan@...enfreihafen.org>,
        linux-wpan@...r.kernel.org,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Cc:     Michael Hennerich <michael.hennerich@...log.com>,
        Harry Morris <h.morris@...coda.com>,
        Varka Bhadram <varkabhadram@...il.com>,
        Xue Liu <liuxuenetmail@...il.com>, Alan Ott <alan@...nal11.us>,
        David Girault <david.girault@...vo.com>,
        Romuald Despres <romuald.despres@...vo.com>,
        Frederic Blain <frederic.blain@...vo.com>,
        Nicolas Schodet <nico@...fr.eu.org>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        linux-wireless@...r.kernel.org,
        Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [wpan-next v2 02/27] net: mac802154: Ensure proper channel selection at probe time

Right now device drivers are encouraged to just set the ->current_page
and ->current_channel to indicate about the current state of the
hardware but this is far from ideal given the fact that we might want to
configure a few things internally, such as the symbol duration.

Call the ieee802154_change_channel() helper from the code section
registering the hardware to ensure proper channel selection and
configuration both on the device side and the core side.

This change somehow "fixes" the hwsim driver which advertises using page
0 channel 13, but does not actually update its own internal pib
structure to reflect that configuration.

Signed-off-by: Miquel Raynal <miquel.raynal@...tlin.com>
---
 net/mac802154/cfg.c          | 3 +--
 net/mac802154/ieee802154_i.h | 1 +
 net/mac802154/main.c         | 8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 870e442bbff0..6969f1330ccd 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -102,8 +102,7 @@ ieee802154_del_iface(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev)
 	return 0;
 }
 
-static int
-ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
+int ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
 {
 	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
 	int ret;
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 702560acc8ce..8a7f4c83c5b6 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -127,6 +127,7 @@ ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
 netdev_tx_t
 ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
 enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
+int ieee802154_change_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel);
 
 /* MIB callbacks */
 void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 520cedc594e1..12ab1545e871 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -157,6 +157,14 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
 
 	ieee802154_setup_wpan_phy_pib(local->phy);
 
+	/* Ensure proper channel selection */
+	rtnl_lock();
+	rc = ieee802154_change_channel(local->phy, local->phy->current_page,
+				       local->phy->current_channel);
+	rtnl_unlock();
+	if (rc)
+		goto out_wq;
+
 	if (!(hw->flags & IEEE802154_HW_CSMA_PARAMS)) {
 		local->phy->supported.min_csma_backoffs = 4;
 		local->phy->supported.max_csma_backoffs = 4;
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ