mirror of https://github.com/hak5/openwrt-owl.git
swconfig: Check vlan/port indexes for validity.
Swconfig needs to make sure that requested vlans/ports actually exist, else it might read or modify memory not belonging to itself. This patch adds a quick range check in swconfig's kernel part to prevent accidential or intentional memory modification. Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@gmail.com> SVN-Revision: 20811owl
parent
2de2c9ead2
commit
fba1a0a074
|
@ -463,6 +463,8 @@ swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
|
||||||
if (!info->attrs[SWITCH_ATTR_OP_VLAN])
|
if (!info->attrs[SWITCH_ATTR_OP_VLAN])
|
||||||
goto done;
|
goto done;
|
||||||
val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]);
|
val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_VLAN]);
|
||||||
|
if (val->port_vlan >= dev->vlans)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
case SWITCH_CMD_SET_PORT:
|
case SWITCH_CMD_SET_PORT:
|
||||||
case SWITCH_CMD_GET_PORT:
|
case SWITCH_CMD_GET_PORT:
|
||||||
|
@ -473,6 +475,8 @@ swconfig_lookup_attr(struct switch_dev *dev, struct genl_info *info,
|
||||||
if (!info->attrs[SWITCH_ATTR_OP_PORT])
|
if (!info->attrs[SWITCH_ATTR_OP_PORT])
|
||||||
goto done;
|
goto done;
|
||||||
val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]);
|
val->port_vlan = nla_get_u32(info->attrs[SWITCH_ATTR_OP_PORT]);
|
||||||
|
if (val->port_vlan >= dev->ports)
|
||||||
|
goto done;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN_ON(1);
|
WARN_ON(1);
|
||||||
|
|
Loading…
Reference in New Issue