Skip to content

Commit

Permalink
net, compat_ioctl: handle more ioctls correctly
Browse files Browse the repository at this point in the history
The MII ioctls and SIOCSIFNAME need to go through ifsioc conversion,
which they never did so far. Some others are not implemented in the
native path, so we can just return -EINVAL directly.

Add IFSLAVE ioctls to the EINVAL list and move it to the end to
optimize the code path for the common case.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
arndb authored and davem330 committed Nov 7, 2009
1 parent 6b96018 commit 9177efd
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -3069,11 +3069,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
return do_siocgstamp(net, sock, cmd, argp);
case SIOCGSTAMPNS:
return do_siocgstampns(net, sock, cmd, argp);
/* Note SIOCRTMSG is no longer, so this is safe and
* the user would have seen just an -EINVAL anyways. */
case SIOCRTMSG:
case SIOCGIFCOUNT:
return -EINVAL;

case FIOSETOWN:
case SIOCSPGRP:
Expand Down Expand Up @@ -3107,8 +3102,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCSIFHWBROADCAST:
case SIOCSHWTSTAMP:
case SIOCDIFADDR:
/* case SIOCSARP: duplicate */
/* case SIOCDARP: duplicate */
case SIOCGIFBRDADDR:
case SIOCSIFBRDADDR:
case SIOCGIFDSTADDR:
Expand All @@ -3121,7 +3114,12 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCSIFTXQLEN:
case SIOCBRADDIF:
case SIOCBRDELIF:
case SIOCSIFNAME:
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
return dev_ifsioc(net, sock, cmd, argp);

case ATM_GETLINKRATE32:
case ATM_GETNAMES32:
case ATM_GETTYPE32:
Expand Down Expand Up @@ -3168,17 +3166,22 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCSARP:
case SIOCGARP:
case SIOCDARP:

case SIOCATMARK:
case SIOCSIFLINK:
case SIOCSIFNAME:
return sock_do_ioctl(net, sock, cmd, arg);
}

/* Prevent warning from compat_sys_ioctl, these always
* result in -EINVAL in the native case anyway. */
switch (cmd) {
case SIOCRTMSG:
case SIOCGIFCOUNT:
case SIOCSRARP:
case SIOCGRARP:
case SIOCDRARP:
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
return sock_do_ioctl(net, sock, cmd, arg);
case SIOCSIFLINK:
case SIOCGIFSLAVE:
case SIOCSIFSLAVE:
return -EINVAL;
}

return -ENOIOCTLCMD;
Expand Down

0 comments on commit 9177efd

Please sign in to comment.