aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qlogic/netxen
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vz@mleia.com>2015-05-25 20:50:04 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-27 00:25:33 -0400
commit748a7295d7242bc1aaaec0e245cc61f2be754766 (patch)
tree161b2291bb05f5b0b3fd4e3339525665badbbfb2 /drivers/net/ethernet/qlogic/netxen
parent082739aa458a74add9a2362988e5aca0367bfa53 (diff)
net: netxen: correct sysfs bin attribute return code
If read() syscall requests unexpected number of bytes from "dimm" binary attribute file, return EINVAL instead of EPERM. At the same time pin down sysfs file size to the fixed sizeof(struct netxen_dimm_cfg), which allows to exploit some missing sanity checks from kernfs (file boundary checks vs offset etc.) Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qlogic/netxen')
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index e0c31e3947d1..6409a06bbdf6 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -3025,9 +3025,9 @@ netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj,
3025 u8 dw, rows, cols, banks, ranks; 3025 u8 dw, rows, cols, banks, ranks;
3026 u32 val; 3026 u32 val;
3027 3027
3028 if (size != sizeof(struct netxen_dimm_cfg)) { 3028 if (size < attr->size) {
3029 netdev_err(netdev, "Invalid size\n"); 3029 netdev_err(netdev, "Invalid size\n");
3030 return -1; 3030 return -EINVAL;
3031 } 3031 }
3032 3032
3033 memset(&dimm, 0, sizeof(struct netxen_dimm_cfg)); 3033 memset(&dimm, 0, sizeof(struct netxen_dimm_cfg));
@@ -3137,7 +3137,7 @@ out:
3137 3137
3138static struct bin_attribute bin_attr_dimm = { 3138static struct bin_attribute bin_attr_dimm = {
3139 .attr = { .name = "dimm", .mode = (S_IRUGO | S_IWUSR) }, 3139 .attr = { .name = "dimm", .mode = (S_IRUGO | S_IWUSR) },
3140 .size = 0, 3140 .size = sizeof(struct netxen_dimm_cfg),
3141 .read = netxen_sysfs_read_dimm, 3141 .read = netxen_sysfs_read_dimm,
3142}; 3142};
3143 3143