Skip to contentSkip to conversation

PROBLEM: plip_ioctl do not check cmd param equal to SIOCDEVPLIP

DISCUSSION sylvain ferriol 1 participant 1 message Jun 1, 2004

lore
Share & tools
lore
#0 lore raw

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