Commit 6131a260 authored by Francois Romieu's avatar Francois Romieu Committed by Jeff Garzik

tehuti: check register size

Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 5a0e2cd5
...@@ -625,6 +625,12 @@ static void __init bdx_firmware_endianess(void) ...@@ -625,6 +625,12 @@ static void __init bdx_firmware_endianess(void)
s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]);
} }
static int bdx_range_check(struct bdx_priv *priv, u32 offset)
{
return (offset > (u32) (BDX_REGS_SIZE / priv->nic->port_num)) ?
-EINVAL : 0;
}
static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
{ {
struct bdx_priv *priv = ndev->priv; struct bdx_priv *priv = ndev->priv;
...@@ -646,6 +652,9 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) ...@@ -646,6 +652,9 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
switch (data[0]) { switch (data[0]) {
case BDX_OP_READ: case BDX_OP_READ:
error = bdx_range_check(priv, data[1]);
if (error < 0)
return error;
data[2] = READ_REG(priv, data[1]); data[2] = READ_REG(priv, data[1]);
DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2],
data[2]); data[2]);
...@@ -655,6 +664,11 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) ...@@ -655,6 +664,11 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
break; break;
case BDX_OP_WRITE: case BDX_OP_WRITE:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
error = bdx_range_check(priv, data[1]);
if (error < 0)
return error;
WRITE_REG(priv, data[1], data[2]); WRITE_REG(priv, data[1], data[2]);
DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment