Skip to content

Commit

Permalink
net: change return values from -EACCES to -EPERM
Browse files Browse the repository at this point in the history
Change return value from -EACCES to -EPERM when the permission check fails.

Signed-off-by: Zhao Hongjiang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Zhao Hongjiang authored and davem330 committed Sep 21, 2012
1 parent e0c7a4a commit bf5b30b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions net/bluetooth/bnep/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) {
case BNEPCONNADD:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT;
Expand All @@ -84,7 +84,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long

case BNEPCONNDEL:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT;
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/cmtp/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) {
case CMTPCONNADD:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT;
Expand All @@ -97,7 +97,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long

case CMTPCONNDEL:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT;
Expand Down
16 changes: 8 additions & 8 deletions net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,
switch (cmd) {
case HCISETRAW:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
return -EPERM;
Expand All @@ -510,12 +510,12 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,

case HCIBLOCKADDR:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_sock_blacklist_add(hdev, (void __user *) arg);

case HCIUNBLOCKADDR:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_sock_blacklist_del(hdev, (void __user *) arg);

default:
Expand Down Expand Up @@ -546,22 +546,22 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,

case HCIDEVUP:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_dev_open(arg);

case HCIDEVDOWN:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_dev_close(arg);

case HCIDEVRESET:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_dev_reset(arg);

case HCIDEVRESTAT:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_dev_reset_stat(arg);

case HCISETSCAN:
Expand All @@ -573,7 +573,7 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd,
case HCISETACLMTU:
case HCISETSCOMTU:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;
return hci_dev_cmd(cmd, argp);

case HCIINQUIRY:
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/hidp/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
switch (cmd) {
case HIDPCONNADD:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&ca, argp, sizeof(ca)))
return -EFAULT;
Expand Down Expand Up @@ -91,7 +91,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long

case HIDPCONNDEL:
if (!capable(CAP_NET_ADMIN))
return -EACCES;
return -EPERM;

if (copy_from_user(&cd, argp, sizeof(cd)))
return -EFAULT;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,15 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
break;

case SIOCSIFFLAGS:
ret = -EACCES;
ret = -EPERM;
if (!capable(CAP_NET_ADMIN))
goto out;
break;
case SIOCSIFADDR: /* Set interface address (and family) */
case SIOCSIFBRDADDR: /* Set the broadcast address */
case SIOCSIFDSTADDR: /* Set the destination address */
case SIOCSIFNETMASK: /* Set the netmask for the interface */
ret = -EACCES;
ret = -EPERM;
if (!capable(CAP_NET_ADMIN))
goto out;
ret = -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion net/netrom/af_netrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (!capable(CAP_NET_BIND_SERVICE)) {
dev_put(dev);
release_sock(sk);
return -EACCES;
return -EPERM;
}
nr->user_addr = addr->fsa_digipeater[0];
nr->source_addr = addr->fsa_ax25.sax25_call;
Expand Down

0 comments on commit bf5b30b

Please sign in to comment.