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]
Date:   Fri, 14 Sep 2018 16:01:31 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     netdev@...r.kernel.org
Cc:     rmk+kernel@...linux.org.uk,
        Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        "David S. Miller" <davem@...emloft.net>,
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH net] net: phy: sfp: Prevent NULL deference of socket_ops

In case we have specified a SFP and an I2C phandle in the Device Tree,
but we somehow failed to look up the I2C adapter (e.g: the driver is not
enabled), we will leave dangling socket_ops, and the sfp_bus will still
have been registered. We can then observe NULL pointer dereferences
while doing ethtool -m:

[   20.218613] Unable to handle kernel NULL pointer dereference at virtual address 00000008
[   20.226977] pgd = (ptrval)
[   20.229785] [00000008] *pgd=7c400831, *pte=00000000, *ppte=00000000
[   20.236274] Internal error: Oops: 17 [#1] SMP ARM
[   20.241122] Modules linked in:
[   20.244278] CPU: 0 PID: 1480 Comm: ethtool Not tainted 4.19.0-rc3 #138
[   20.251013] Hardware name: Broadcom Northstar Plus SoC
[   20.256316] PC is at sfp_get_module_info+0x8/0x10
[   20.261172] LR is at dev_ethtool+0x218c/0x2afc

Specifically guard against that.

Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages")
Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
 drivers/net/phy/sfp-bus.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index 740655261e5b..9465be501372 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -378,6 +378,9 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
  */
 int sfp_get_module_info(struct sfp_bus *bus, struct ethtool_modinfo *modinfo)
 {
+	if (!bus->socket_ops)
+		return -EOPNOTSUPP;
+
 	return bus->socket_ops->module_info(bus->sfp, modinfo);
 }
 EXPORT_SYMBOL_GPL(sfp_get_module_info);
@@ -396,6 +399,9 @@ EXPORT_SYMBOL_GPL(sfp_get_module_info);
 int sfp_get_module_eeprom(struct sfp_bus *bus, struct ethtool_eeprom *ee,
 			  u8 *data)
 {
+	if (!bus->socket_ops)
+		return -EOPNOTSUPP;
+
 	return bus->socket_ops->module_eeprom(bus->sfp, ee, data);
 }
 EXPORT_SYMBOL_GPL(sfp_get_module_eeprom);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ