PROBLEM: plip_ioctl do not check cmd param equal to SIOCDEVPLIP

From: sylvain ferriol
Date: Tue Jun 01 2004 - 18:10:50 EST


as plip_ioctl do not check the command in cmd parameter, it can return 0 to an ioctl access which is not for him.

example: in wireless-tools package
to check if the network interface is a wireless interface,
the wireless tool send an ioctl with cmd=SIOCGIWNAME

as plip_ioctl do not have a 'switch case' on cmd param, it returns 0
=> plip is assigned as a wireless interface => bug

One example code fix:
static int
plip_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct net_local *nl = (struct net_local *) dev->priv;
struct plipconf *pc = (struct plipconf *) &rq->ifr_data;

+ if(cmd != SIOCDEVPLIP) {
+ return -EOPNOTSUPP;
+ }

switch(pc->pcmd) {
case PLIP_GET_TIMEOUT:
pc->trigger = nl->trigger;
pc->nibble = nl->nibble;
break;
case PLIP_SET_TIMEOUT:
if(!capable(CAP_NET_ADMIN))
return -EPERM;
nl->trigger = pc->trigger;
nl->nibble = pc->nibble;
break;
default:
return -EOPNOTSUPP;
}
return 0;
}

thanks
sylvain ferriol

Keywords: module, plip, networking
Kernel version: 2.4.26

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/