Skip to content

Commit

Permalink
appletalk: use ndo_siocdevprivate
Browse files Browse the repository at this point in the history
appletalk has three SIOCDEVPRIVATE ioctl commands that are
broken in compat mode because the passed structure contains
a pointer.

Change it over to ndo_siocdevprivate for consistency and
make it return an error when called in compat mode. This
could be fixed if there are still users.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arnd Bergmann authored and David S. Miller committed Jul 27, 2021
1 parent 232ec98 commit dbecb01
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/net/appletalk/ipddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ static netdev_tx_t ipddp_xmit(struct sk_buff *skb,
static int ipddp_create(struct ipddp_route *new_rt);
static int ipddp_delete(struct ipddp_route *rt);
static struct ipddp_route* __ipddp_find_route(struct ipddp_route *rt);
static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static int ipddp_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
void __user *data, int cmd);

static const struct net_device_ops ipddp_netdev_ops = {
.ndo_start_xmit = ipddp_xmit,
.ndo_do_ioctl = ipddp_ioctl,
.ndo_siocdevprivate = ipddp_siocdevprivate,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
Expand Down Expand Up @@ -268,15 +269,18 @@ static struct ipddp_route* __ipddp_find_route(struct ipddp_route *rt)
return NULL;
}

static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static int ipddp_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
void __user *data, int cmd)
{
struct ipddp_route __user *rt = ifr->ifr_data;
struct ipddp_route rcp, rcp2, *rp;

if (in_compat_syscall())
return -EOPNOTSUPP;

if(!capable(CAP_NET_ADMIN))
return -EPERM;

if(copy_from_user(&rcp, rt, sizeof(rcp)))
if (copy_from_user(&rcp, data, sizeof(rcp)))
return -EFAULT;

switch(cmd)
Expand All @@ -296,7 +300,7 @@ static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
spin_unlock_bh(&ipddp_route_lock);

if (rp) {
if (copy_to_user(rt, &rcp2,
if (copy_to_user(data, &rcp2,
sizeof(struct ipddp_route)))
return -EFAULT;
return 0;
Expand Down

0 comments on commit dbecb01

Please sign in to comment.