diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2008-04-20 13:32:34 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-25 02:08:09 -0400 |
commit | 6131a2601f42cd7fdbac0e960713396fe68af59f (patch) | |
tree | d3f518e4f7af61164db2397bd86558b01cff5b70 /drivers | |
parent | 5a0e2cd51145748c4fd44d0c3a06d39eb87e8725 (diff) |
tehuti: check register size
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/tehuti.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c index 17585e5eed53..d2e1b219673d 100644 --- a/drivers/net/tehuti.c +++ b/drivers/net/tehuti.c | |||
@@ -625,6 +625,12 @@ static void __init bdx_firmware_endianess(void) | |||
625 | s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); | 625 | s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); |
626 | } | 626 | } |
627 | 627 | ||
628 | static int bdx_range_check(struct bdx_priv *priv, u32 offset) | ||
629 | { | ||
630 | return (offset > (u32) (BDX_REGS_SIZE / priv->nic->port_num)) ? | ||
631 | -EINVAL : 0; | ||
632 | } | ||
633 | |||
628 | static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | 634 | static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) |
629 | { | 635 | { |
630 | struct bdx_priv *priv = ndev->priv; | 636 | 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 | switch (data[0]) { | 652 | switch (data[0]) { |
647 | 653 | ||
648 | case BDX_OP_READ: | 654 | case BDX_OP_READ: |
655 | error = bdx_range_check(priv, data[1]); | ||
656 | if (error < 0) | ||
657 | return error; | ||
649 | data[2] = READ_REG(priv, data[1]); | 658 | data[2] = READ_REG(priv, data[1]); |
650 | DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], | 659 | DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], |
651 | data[2]); | 660 | data[2]); |
@@ -655,6 +664,11 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | |||
655 | break; | 664 | break; |
656 | 665 | ||
657 | case BDX_OP_WRITE: | 666 | case BDX_OP_WRITE: |
667 | if (!capable(CAP_NET_ADMIN)) | ||
668 | return -EPERM; | ||
669 | error = bdx_range_check(priv, data[1]); | ||
670 | if (error < 0) | ||
671 | return error; | ||
658 | WRITE_REG(priv, data[1], data[2]); | 672 | WRITE_REG(priv, data[1], data[2]); |
659 | DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); | 673 | DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); |
660 | break; | 674 | break; |