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:   Tue,  3 Mar 2020 09:22:52 +0100 (CET)
From:   Michal Kubecek <mkubecek@...e.cz>
To:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org
Subject: [PATCH net] tun: fix ethtool_ops get_msglvl and set_msglvl handlers

The get_msglvl and setmsglvl handlers only work as expected if TUN_DEBUG
is defined (which required editing the source). Otherwise tun_get_msglvl()
returns -EOPNOTSUPP but as this handler is not supposed to return error
code, it is not recognized as one and passed to userspace as is, resulting
in bogus output of ethtool command. The set_msglvl handler ignores its
argument and does nothing if TUN_DEBUG is left undefined.

The way to return EOPNOTSUPP to userspace for both requests is not to
provide these ethtool_ops callbacks at all if TUN_DEBUG is left undefined.

Signed-off-by: Michal Kubecek <mkubecek@...e.cz>
---
 drivers/net/tun.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 650c937ed56b..0aae2d208398 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -3557,23 +3557,21 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
 	}
 }
 
+#ifdef TUN_DEBUG
 static u32 tun_get_msglevel(struct net_device *dev)
 {
-#ifdef TUN_DEBUG
 	struct tun_struct *tun = netdev_priv(dev);
+
 	return tun->debug;
-#else
-	return -EOPNOTSUPP;
-#endif
 }
 
 static void tun_set_msglevel(struct net_device *dev, u32 value)
 {
-#ifdef TUN_DEBUG
 	struct tun_struct *tun = netdev_priv(dev);
+
 	tun->debug = value;
-#endif
 }
+#endif /* TUN_DEBUG */
 
 static int tun_get_coalesce(struct net_device *dev,
 			    struct ethtool_coalesce *ec)
@@ -3600,8 +3598,10 @@ static int tun_set_coalesce(struct net_device *dev,
 
 static const struct ethtool_ops tun_ethtool_ops = {
 	.get_drvinfo	= tun_get_drvinfo,
+#ifdef TUN_DEBUG
 	.get_msglevel	= tun_get_msglevel,
 	.set_msglevel	= tun_set_msglevel,
+#endif
 	.get_link	= ethtool_op_get_link,
 	.get_ts_info	= ethtool_op_get_ts_info,
 	.get_coalesce   = tun_get_coalesce,
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ