SIOCGMIIREG and SIOCSMIIREG access a user data structure via a void pointer to user space. So, we need copy_from_user and copy_to_user to move the data.
Signed-off-by: Steven A. Falco <sfa...@harris.com> --- I believe there is a bug in the way the ibm_newemac driver handles the SIOCGMIIREG (and SIOCSMIIREG) ioctl. The problem is that emac_ioctl is handed a "struct ifreq *rq" which contains a user-land pointer to an array of 16-bit integers. However, emac_ioctl directly accesses the data, which doesn't work. I added the following patch to copy the data in and out. Please note that this patch was tested in an older kernel (2.6.30) because that is what we are using on our custom hardware. I think this is still a problem in the current code, but I'd like reviewers to take a look, to be sure. --- drivers/net/ibm_newemac/core.c 2010-06-09 19:57:26.000000000 -0400 +++ /home/sfalco/core.c 2010-06-10 09:38:22.000000000 -0400 @@ -2218,6 +2218,7 @@ { struct emac_instance *dev = netdev_priv(ndev); struct mii_ioctl_data *data = if_mii(rq); + struct mii_ioctl_data user_data; DBG(dev, "ioctl %08x" NL, cmd); @@ -2229,13 +2230,19 @@ data->phy_id = dev->phy.address; /* Fall through */ case SIOCGMIIREG: - data->val_out = emac_mdio_read(ndev, dev->phy.address, - data->reg_num); + if (copy_from_user(user_data, (char __user *)data, sizeof(user_data))) + return -EFAULT; + user_data->val_out = emac_mdio_read(ndev, dev->phy.address, + user_data->reg_num); + if (copy_to_user((char __user *)rq->ifr_data, user_data, sizeof(user_data))) + return -EFAULT; return 0; case SIOCSMIIREG: - emac_mdio_write(ndev, dev->phy.address, data->reg_num, - data->val_in); + if (copy_from_user(user_data, (char __user *)data, sizeof(user_data))) + return -EFAULT; + emac_mdio_write(ndev, dev->phy.address, user_data->reg_num, + user_data->val_in); return 0; default: return -EOPNOTSUPP; _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev