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>] [day] [month] [year] [list]
Message-Id: <20190218180255.15822-1-julius.n@gmx.net>
Date:   Mon, 18 Feb 2019 19:02:49 +0100
From:   Julius Niedworok <julius.n@....net>
To:     netdev@...r.kernel.org
Cc:     julius.n@....net, ga58taw@...um.de,
        "David S. Miller" <davem@...emloft.net>,
        Alexander Duyck <alexander.h.duyck@...el.com>,
        Tyler Hicks <tyhicks@...onical.com>,
        Amritha Nambiar <amritha.nambiar@...el.com>,
        Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
        Petr Machata <petrm@...lanox.com>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Joe Perches <joe@...ches.com>, linux-kernel@...r.kernel.org
Subject: [PATCH RFC] net-sysfs: consistent behavior between ioctl and sysfs

The flags of a network interface can be read either from
/sys/class/net/<dev>/flags or from the ioctl SIOCGIFFLAGS. When the ioctl
is used, dev_get_flags is called to extract the flags. However, reads on
the sysfs file return the plain content of the flags integer and do not
call dev_get_flags.

In order to fix this inconsistent behavior, replace the NETDEVICE_SHOW_RW
macro by the functions format_flags and flags_show. These functions extract
the flags by calling dev_get_flags and return them formatted for the user.

This makes the behavior between calling the SIOCGIFFLAGS ioctl and reading
/sys/class/net/<dev>/flags consistent.

Co-developed-by: Charlie Groh <ga58taw@...um.de>
Signed-off-by: Charlie Groh <ga58taw@...um.de>
Signed-off-by: Julius Niedworok <julius.n@....net>
---
 net/core/net-sysfs.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index ff9fd2b..8ae8be5 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -345,7 +345,19 @@ static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
 {
 	return netdev_store(dev, attr, buf, len, change_flags);
 }
-NETDEVICE_SHOW_RW(flags, fmt_hex);
+
+static ssize_t format_flags(const struct net_device *dev, char *buf)
+{
+	return sprintf(buf, fmt_hex, dev_get_flags(dev));
+}
+
+static ssize_t flags_show(struct device *dev,
+			  struct device_attribute *attr,
+			  char *buf)
+{
+	return netdev_show(dev, attr, buf, format_flags);
+}
+static DEVICE_ATTR_RW(flags);
 
 static ssize_t tx_queue_len_store(struct device *dev,
 				  struct device_attribute *attr,
-- 
2.10.1 (Apple Git-78)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ