diff options
Diffstat (limited to 'net/core/ethtool.c')
| -rw-r--r-- | net/core/ethtool.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 27ce1683caf5..87dc556fd9d6 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -143,7 +143,7 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr) | |||
| 143 | static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) | 143 | static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) |
| 144 | { | 144 | { |
| 145 | struct ethtool_drvinfo info; | 145 | struct ethtool_drvinfo info; |
| 146 | struct ethtool_ops *ops = dev->ethtool_ops; | 146 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 147 | 147 | ||
| 148 | if (!ops->get_drvinfo) | 148 | if (!ops->get_drvinfo) |
| 149 | return -EOPNOTSUPP; | 149 | return -EOPNOTSUPP; |
| @@ -169,7 +169,7 @@ static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) | |||
| 169 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) | 169 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) |
| 170 | { | 170 | { |
| 171 | struct ethtool_regs regs; | 171 | struct ethtool_regs regs; |
| 172 | struct ethtool_ops *ops = dev->ethtool_ops; | 172 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 173 | void *regbuf; | 173 | void *regbuf; |
| 174 | int reglen, ret; | 174 | int reglen, ret; |
| 175 | 175 | ||
| @@ -282,7 +282,7 @@ static int ethtool_get_link(struct net_device *dev, void __user *useraddr) | |||
| 282 | static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr) | 282 | static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr) |
| 283 | { | 283 | { |
| 284 | struct ethtool_eeprom eeprom; | 284 | struct ethtool_eeprom eeprom; |
| 285 | struct ethtool_ops *ops = dev->ethtool_ops; | 285 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 286 | u8 *data; | 286 | u8 *data; |
| 287 | int ret; | 287 | int ret; |
| 288 | 288 | ||
| @@ -327,7 +327,7 @@ static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr) | |||
| 327 | static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) | 327 | static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) |
| 328 | { | 328 | { |
| 329 | struct ethtool_eeprom eeprom; | 329 | struct ethtool_eeprom eeprom; |
| 330 | struct ethtool_ops *ops = dev->ethtool_ops; | 330 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 331 | u8 *data; | 331 | u8 *data; |
| 332 | int ret; | 332 | int ret; |
| 333 | 333 | ||
| @@ -437,7 +437,7 @@ static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr) | |||
| 437 | { | 437 | { |
| 438 | struct ethtool_pauseparam pauseparam; | 438 | struct ethtool_pauseparam pauseparam; |
| 439 | 439 | ||
| 440 | if (!dev->ethtool_ops->get_pauseparam) | 440 | if (!dev->ethtool_ops->set_pauseparam) |
| 441 | return -EOPNOTSUPP; | 441 | return -EOPNOTSUPP; |
| 442 | 442 | ||
| 443 | if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam))) | 443 | if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam))) |
| @@ -640,7 +640,7 @@ static int ethtool_set_gso(struct net_device *dev, char __user *useraddr) | |||
| 640 | static int ethtool_self_test(struct net_device *dev, char __user *useraddr) | 640 | static int ethtool_self_test(struct net_device *dev, char __user *useraddr) |
| 641 | { | 641 | { |
| 642 | struct ethtool_test test; | 642 | struct ethtool_test test; |
| 643 | struct ethtool_ops *ops = dev->ethtool_ops; | 643 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 644 | u64 *data; | 644 | u64 *data; |
| 645 | int ret; | 645 | int ret; |
| 646 | 646 | ||
| @@ -673,7 +673,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr) | |||
| 673 | static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) | 673 | static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) |
| 674 | { | 674 | { |
| 675 | struct ethtool_gstrings gstrings; | 675 | struct ethtool_gstrings gstrings; |
| 676 | struct ethtool_ops *ops = dev->ethtool_ops; | 676 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 677 | u8 *data; | 677 | u8 *data; |
| 678 | int ret; | 678 | int ret; |
| 679 | 679 | ||
| @@ -733,7 +733,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
| 733 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) | 733 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) |
| 734 | { | 734 | { |
| 735 | struct ethtool_stats stats; | 735 | struct ethtool_stats stats; |
| 736 | struct ethtool_ops *ops = dev->ethtool_ops; | 736 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 737 | u64 *data; | 737 | u64 *data; |
| 738 | int ret; | 738 | int ret; |
| 739 | 739 | ||
| @@ -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,27 @@ int dev_ethtool(struct ifreq *ifr) | |||
| 822 | if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd))) | 815 | if (copy_from_user(ðcmd, 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_GDRVINFO: | ||
| 821 | case ETHTOOL_GMSGLVL: | ||
| 822 | case ETHTOOL_GCOALESCE: | ||
| 823 | case ETHTOOL_GRINGPARAM: | ||
| 824 | case ETHTOOL_GPAUSEPARAM: | ||
| 825 | case ETHTOOL_GRXCSUM: | ||
| 826 | case ETHTOOL_GTXCSUM: | ||
| 827 | case ETHTOOL_GSG: | ||
| 828 | case ETHTOOL_GSTRINGS: | ||
| 829 | case ETHTOOL_GTSO: | ||
| 830 | case ETHTOOL_GPERMADDR: | ||
| 831 | case ETHTOOL_GUFO: | ||
| 832 | case ETHTOOL_GGSO: | ||
| 833 | break; | ||
| 834 | default: | ||
| 835 | if (!capable(CAP_NET_ADMIN)) | ||
| 836 | return -EPERM; | ||
| 837 | } | ||
| 838 | |||
| 825 | if(dev->ethtool_ops->begin) | 839 | if(dev->ethtool_ops->begin) |
| 826 | if ((rc = dev->ethtool_ops->begin(dev)) < 0) | 840 | if ((rc = dev->ethtool_ops->begin(dev)) < 0) |
| 827 | return rc; | 841 | return rc; |
| @@ -947,6 +961,10 @@ int dev_ethtool(struct ifreq *ifr) | |||
| 947 | return rc; | 961 | return rc; |
| 948 | 962 | ||
| 949 | ioctl: | 963 | ioctl: |
| 964 | /* Keep existing behaviour for the moment. */ | ||
| 965 | if (!capable(CAP_NET_ADMIN)) | ||
| 966 | return -EPERM; | ||
| 967 | |||
| 950 | if (dev->do_ioctl) | 968 | if (dev->do_ioctl) |
| 951 | return dev->do_ioctl(dev, ifr, SIOCETHTOOL); | 969 | return dev->do_ioctl(dev, ifr, SIOCETHTOOL); |
| 952 | return -EOPNOTSUPP; | 970 | return -EOPNOTSUPP; |
