aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/ethtool.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e0ca04f38cef..120786a196d0 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -806,13 +806,6 @@ int dev_ethtool(struct ifreq *ifr)
806 int rc; 806 int rc;
807 unsigned long old_features; 807 unsigned long old_features;
808 808
809 /*
810 * XXX: This can be pushed down into the ethtool_* handlers that
811 * need it. Keep existing behaviour for the moment.
812 */
813 if (!capable(CAP_NET_ADMIN))
814 return -EPERM;
815
816 if (!dev || !netif_device_present(dev)) 809 if (!dev || !netif_device_present(dev))
817 return -ENODEV; 810 return -ENODEV;
818 811
@@ -822,6 +815,31 @@ int dev_ethtool(struct ifreq *ifr)
822 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd))) 815 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
823 return -EFAULT; 816 return -EFAULT;
824 817
818 /* Allow some commands to be done by anyone */
819 switch(ethcmd) {
820 case ETHTOOL_GSET:
821 case ETHTOOL_GDRVINFO:
822 case ETHTOOL_GWOL:
823 case ETHTOOL_GMSGLVL:
824 case ETHTOOL_GLINK:
825 case ETHTOOL_GCOALESCE:
826 case ETHTOOL_GRINGPARAM:
827 case ETHTOOL_GPAUSEPARAM:
828 case ETHTOOL_GRXCSUM:
829 case ETHTOOL_GTXCSUM:
830 case ETHTOOL_GSG:
831 case ETHTOOL_GSTRINGS:
832 case ETHTOOL_GSTATS:
833 case ETHTOOL_GTSO:
834 case ETHTOOL_GPERMADDR:
835 case ETHTOOL_GUFO:
836 case ETHTOOL_GGSO:
837 break;
838 default:
839 if (!capable(CAP_NET_ADMIN))
840 return -EPERM;
841 }
842
825 if(dev->ethtool_ops->begin) 843 if(dev->ethtool_ops->begin)
826 if ((rc = dev->ethtool_ops->begin(dev)) < 0) 844 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
827 return rc; 845 return rc;
@@ -947,6 +965,10 @@ int dev_ethtool(struct ifreq *ifr)
947 return rc; 965 return rc;
948 966
949 ioctl: 967 ioctl:
968 /* Keep existing behaviour for the moment. */
969 if (!capable(CAP_NET_ADMIN))
970 return -EPERM;
971
950 if (dev->do_ioctl) 972 if (dev->do_ioctl)
951 return dev->do_ioctl(dev, ifr, SIOCETHTOOL); 973 return dev->do_ioctl(dev, ifr, SIOCETHTOOL);
952 return -EOPNOTSUPP; 974 return -EOPNOTSUPP;