net-sysfs: require net admin in the init ns for setting tx_maxrate
authorTyler Hicks <tyhicks@canonical.com>
Fri, 20 Jul 2018 21:56:51 +0000 (21:56 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 21 Jul 2018 06:44:35 +0000 (23:44 -0700)
An upcoming change will allow container root to open some /sys/class/net
files for writing. The tx_maxrate attribute can result in changes
to actual hardware devices so err on the side of caution by requiring
CAP_NET_ADMIN in the init namespace in the corresponding attribute store
operation.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/net-sysfs.c

index ffa1d18f2c2ce4915ed741515885dfebf6996ae3..405c41ecb20b4d1149a745692bbb3dad9c1b5870 100644 (file)
@@ -1087,6 +1087,9 @@ static ssize_t tx_maxrate_store(struct netdev_queue *queue,
        int err, index = get_netdev_queue_index(queue);
        u32 rate = 0;
 
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
        err = kstrtou32(buf, 10, &rate);
        if (err < 0)
                return err;