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]
Message-Id: <20210613145859.1774246-2-code@reto-schneider.ch>
Date:   Sun, 13 Jun 2021 16:59:01 +0200
From:   Reto Schneider <code@...o-schneider.ch>
To:     devicetree@...r.kernel.org, linux-mediatek@...ts.infradead.org,
        netdev@...r.kernel.org
Cc:     Stefan Roese <sr@...x.de>,
        Reto Schneider <reto.schneider@...qvarnagroup.com>,
        "David S. Miller" <davem@...emloft.net>,
        Felix Fietkau <nbd@....name>, Jakub Kicinski <kuba@...nel.org>,
        John Crispin <john@...ozen.org>,
        Mark Lee <Mark-MC.Lee@...iatek.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Russell King <linux@...linux.org.uk>,
        Sean Wang <sean.wang@...iatek.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/2] net: ethernet: mtk_eth_soc: Support custom ifname

From: Reto Schneider <reto.schneider@...qvarnagroup.com>

Name the MAC interface name according to the label property. If the
property is missing, the default name (ethX) gets used.

Labels with more than IFNAMSIZ -1 characters will be truncated silently,
which seems to be what most of the code base does when using strscpy.

Signed-off-by: Reto Schneider <reto.schneider@...qvarnagroup.com>

---

Changes in v2:
- Avoid dangerous usage of strncpy

 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 64adfd24e134..a921ecc1c997 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2948,6 +2948,7 @@ static const struct net_device_ops mtk_netdev_ops = {
 static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 {
 	const __be32 *_id = of_get_property(np, "reg", NULL);
+	const char *const name = of_get_property(np, "label", NULL);
 	phy_interface_t phy_mode;
 	struct phylink *phylink;
 	struct mtk_mac *mac;
@@ -3020,6 +3021,9 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
 
 	mac->phylink = phylink;
 
+	if (name)
+		strscpy(eth->netdev[id]->name, name, IFNAMSIZ);
+
 	SET_NETDEV_DEV(eth->netdev[id], eth->dev);
 	eth->netdev[id]->watchdog_timeo = 5 * HZ;
 	eth->netdev[id]->netdev_ops = &mtk_netdev_ops;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ