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: <20221226114825.1937189-2-d-tatianin@yandex-team.ru>
Date:   Mon, 26 Dec 2022 14:48:23 +0300
From:   Daniil Tatianin <d-tatianin@...dex-team.ru>
To:     "David S. Miller" <davem@...emloft.net>
Cc:     Daniil Tatianin <d-tatianin@...dex-team.ru>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>,
        Sean Anderson <sean.anderson@...o.com>,
        Jiri Pirko <jiri@...dia.com>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        Maxim Korotkov <korotkov.maxim.s@...il.com>,
        Gal Pressman <gal@...dia.com>,
        Vincent Mailhol <mailhol.vincent@...adoo.fr>,
        Tom Rix <trix@...hat.com>, Marco Bonelli <marco@...eim.net>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH net v2 1/3] net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats

It's not very useful to copy back an empty ethtool_stats struct and
return 0 if we didn't actually have any stats. This also allows for
further simplification of this function in the future commits.

Signed-off-by: Daniil Tatianin <d-tatianin@...dex-team.ru>
Reviewed-by: Andrew Lunn <andrew@...n.ch>
---
 net/ethtool/ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 57e7238a4136..e8a294b38b7b 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -2093,7 +2093,8 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
 		return n_stats;
 	if (n_stats > S32_MAX / sizeof(u64))
 		return -ENOMEM;
-	WARN_ON_ONCE(!n_stats);
+	if (WARN_ON_ONCE(!n_stats))
+		return -EOPNOTSUPP;
 
 	if (copy_from_user(&stats, useraddr, sizeof(stats)))
 		return -EFAULT;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ