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-next>] [day] [month] [year] [list]
Message-Id: <20220621134917.24184-1-ysionneau@kalray.eu>
Date:   Tue, 21 Jun 2022 15:49:17 +0200
From:   Yann Sionneau <ysionneau@...ray.eu>
To:     linux-kernel@...r.kernel.org
Cc:     Russell King <linux@...linux.org.uk>, Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
        jvetter@...ray.eu, jmaselbas@...ray.eu,
        Yann Sionneau <ysionneau@...ray.eu>
Subject: [PATCH] net: phylink: check for pcs_ops being NULL

Out of tree drivers that have not been updated
after 001f4261fe4d ("net: phylink: use legacy_pre_march2020") would not set the
legacy_pre_march2020 boolean which if not initialized will default to false.
Such drivers will most likely still be using the legacy interface and will
not have pcs_ops.

Check for pcs_ops being NULL even if driver does not advertise itself
as "pre march 2020 legacy". This commit adds a simple check instead of
dereferencing a NULL pointer and prints an error message to indicate
that the driver needs to be updated.

Signed-off-by: Yann Sionneau <ysionneau@...ray.eu>
---
 drivers/net/phy/phylink.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 06943889d747..94abf418afb1 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -874,6 +874,14 @@ static int phylink_change_inband_advert(struct phylink *pl)
 		return 0;
 	}
 
+	if (unlikely(!pl->pcs_ops)) {
+		phylink_err(pl, "%s: Error, net driver needs to either be "
+			    "updated to use pcs_ops or actually advertise it "
+			    "has legacy interface by setting "
+			    "legacy_pre_march2020 boolean", __func__);
+		return -EINVAL;
+	}
+
 	phylink_dbg(pl, "%s: mode=%s/%s adv=%*pb pause=%02x\n", __func__,
 		    phylink_an_mode_str(pl->cur_link_an_mode),
 		    phy_modes(pl->link_config.interface),
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ