Skip to content

Commit e756058

Browse files
tgrafdavem330
authored andcommitted
rocker: Add proper validation of Netlink attributes
Signed-off-by: Thomas Graf <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Scott Feldman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5111f80 commit e756058

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/net/ethernet/rocker/rocker.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3712,6 +3712,9 @@ static int rocker_port_bridge_setlink(struct net_device *dev,
37123712
if (afspec) {
37133713
attr = nla_find_nested(afspec, IFLA_BRIDGE_MODE);
37143714
if (attr) {
3715+
if (nla_len(attr) < sizeof(mode))
3716+
return -EINVAL;
3717+
37153718
mode = nla_get_u16(attr);
37163719
if (mode != BRIDGE_MODE_SWDEV)
37173720
return -EINVAL;
@@ -3721,6 +3724,9 @@ static int rocker_port_bridge_setlink(struct net_device *dev,
37213724
if (protinfo) {
37223725
attr = nla_find_nested(protinfo, IFLA_BRPORT_LEARNING);
37233726
if (attr) {
3727+
if (nla_len(attr) < sizeof(u8))
3728+
return -EINVAL;
3729+
37243730
if (nla_get_u8(attr))
37253731
rocker_port->brport_flags |= BR_LEARNING;
37263732
else
@@ -3731,6 +3737,9 @@ static int rocker_port_bridge_setlink(struct net_device *dev,
37313737
}
37323738
attr = nla_find_nested(protinfo, IFLA_BRPORT_LEARNING_SYNC);
37333739
if (attr) {
3740+
if (nla_len(attr) < sizeof(u8))
3741+
return -EINVAL;
3742+
37343743
if (nla_get_u8(attr))
37353744
rocker_port->brport_flags |= BR_LEARNING_SYNC;
37363745
else

0 commit comments

Comments
 (0)