Commit bf5b30b8 authored by Zhao Hongjiang's avatar Zhao Hongjiang Committed by David S. Miller

net: change return values from -EACCES to -EPERM

Change return value from -EACCES to -EPERM when the permission check fails.
Signed-off-by: default avatarZhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e0c7a4a1
...@@ -58,7 +58,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -58,7 +58,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) { switch (cmd) {
case BNEPCONNADD: case BNEPCONNADD:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&ca, argp, sizeof(ca))) if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT; return -EFAULT;
...@@ -84,7 +84,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -84,7 +84,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
case BNEPCONNDEL: case BNEPCONNDEL:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&cd, argp, sizeof(cd))) if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT; return -EFAULT;
......
...@@ -72,7 +72,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -72,7 +72,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) { switch (cmd) {
case CMTPCONNADD: case CMTPCONNADD:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&ca, argp, sizeof(ca))) if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT; return -EFAULT;
...@@ -97,7 +97,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -97,7 +97,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
case CMTPCONNDEL: case CMTPCONNDEL:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&cd, argp, sizeof(cd))) if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT; return -EFAULT;
......
...@@ -490,7 +490,7 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, ...@@ -490,7 +490,7 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
switch (cmd) { switch (cmd) {
case HCISETRAW: case HCISETRAW:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
return -EPERM; return -EPERM;
...@@ -510,12 +510,12 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, ...@@ -510,12 +510,12 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
case HCIBLOCKADDR: case HCIBLOCKADDR:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_sock_blacklist_add(hdev, (void __user *) arg); return hci_sock_blacklist_add(hdev, (void __user *) arg);
case HCIUNBLOCKADDR: case HCIUNBLOCKADDR:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_sock_blacklist_del(hdev, (void __user *) arg); return hci_sock_blacklist_del(hdev, (void __user *) arg);
default: default:
...@@ -546,22 +546,22 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, ...@@ -546,22 +546,22 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
case HCIDEVUP: case HCIDEVUP:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_dev_open(arg); return hci_dev_open(arg);
case HCIDEVDOWN: case HCIDEVDOWN:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_dev_close(arg); return hci_dev_close(arg);
case HCIDEVRESET: case HCIDEVRESET:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_dev_reset(arg); return hci_dev_reset(arg);
case HCIDEVRESTAT: case HCIDEVRESTAT:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_dev_reset_stat(arg); return hci_dev_reset_stat(arg);
case HCISETSCAN: case HCISETSCAN:
...@@ -573,7 +573,7 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, ...@@ -573,7 +573,7 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
case HCISETACLMTU: case HCISETACLMTU:
case HCISETSCOMTU: case HCISETSCOMTU:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
return hci_dev_cmd(cmd, argp); return hci_dev_cmd(cmd, argp);
case HCIINQUIRY: case HCIINQUIRY:
......
...@@ -56,7 +56,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -56,7 +56,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) { switch (cmd) {
case HIDPCONNADD: case HIDPCONNADD:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&ca, argp, sizeof(ca))) if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT; return -EFAULT;
...@@ -91,7 +91,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ...@@ -91,7 +91,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
case HIDPCONNDEL: case HIDPCONNDEL:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EACCES; return -EPERM;
if (copy_from_user(&cd, argp, sizeof(cd))) if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT; return -EFAULT;
......
...@@ -725,7 +725,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -725,7 +725,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
break; break;
case SIOCSIFFLAGS: case SIOCSIFFLAGS:
ret = -EACCES; ret = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
goto out; goto out;
break; break;
...@@ -733,7 +733,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -733,7 +733,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
case SIOCSIFBRDADDR: /* Set the broadcast address */ case SIOCSIFBRDADDR: /* Set the broadcast address */
case SIOCSIFDSTADDR: /* Set the destination address */ case SIOCSIFDSTADDR: /* Set the destination address */
case SIOCSIFNETMASK: /* Set the netmask for the interface */ case SIOCSIFNETMASK: /* Set the netmask for the interface */
ret = -EACCES; ret = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
goto out; goto out;
ret = -EINVAL; ret = -EINVAL;
......
...@@ -601,7 +601,7 @@ static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -601,7 +601,7 @@ static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (!capable(CAP_NET_BIND_SERVICE)) { if (!capable(CAP_NET_BIND_SERVICE)) {
dev_put(dev); dev_put(dev);
release_sock(sk); release_sock(sk);
return -EACCES; return -EPERM;
} }
nr->user_addr = addr->fsa_digipeater[0]; nr->user_addr = addr->fsa_digipeater[0];
nr->source_addr = addr->fsa_ax25.sax25_call; nr->source_addr = addr->fsa_ax25.sax25_call;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment