Skip to content

Commit

Permalink
rtnetlink: add the missing IFLA_GRO_ tb check in validate_linkmsg
Browse files Browse the repository at this point in the history
This fixes the issue that dev gro_max_size and gso_ipv4_max_size
can be set to a huge value:

  # ip link add dummy1 type dummy
  # ip link set dummy1 gro_max_size 4294967295
  # ip -d link show dummy1
    dummy addrgenmode eui64 ... gro_max_size 4294967295

Fixes: 0fe79f2 ("net: allow gro_max_size to exceed 65536")
Fixes: 9eefedd ("net: add gso_ipv4_max_size and gro_ipv4_max_size per device")
Reported-by: Xiumei Mu <[email protected]>
Signed-off-by: Xin Long <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
lxin authored and kuba-moo committed Jun 1, 2023
1 parent fef5b22 commit 65d6914
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2399,11 +2399,23 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[],
return -EINVAL;
}

if (tb[IFLA_GRO_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GRO_MAX_SIZE]) > GRO_MAX_SIZE) {
NL_SET_ERR_MSG(extack, "too big gro_max_size");
return -EINVAL;
}

if (tb[IFLA_GSO_IPV4_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GSO_IPV4_MAX_SIZE]) > dev->tso_max_size) {
NL_SET_ERR_MSG(extack, "too big gso_ipv4_max_size");
return -EINVAL;
}

if (tb[IFLA_GRO_IPV4_MAX_SIZE] &&
nla_get_u32(tb[IFLA_GRO_IPV4_MAX_SIZE]) > GRO_MAX_SIZE) {
NL_SET_ERR_MSG(extack, "too big gro_ipv4_max_size");
return -EINVAL;
}
}

if (tb[IFLA_AF_SPEC]) {
Expand Down

0 comments on commit 65d6914

Please sign in to comment.