Message ID | b1fb9330f06ad743b51e50f398b1208d2fb47af6.1685051273.git.lucien.xin@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | rtnetlink: a couple of fixes in linkmsg validation | expand |
On Thu, May 25, 2023 at 05:49:17PM -0400, Xin Long wrote: > 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 |grep gro_max_size > dummy addrgenmode eui64 ... gro_max_size 4294967295 > > Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536") > Fixes: 9eefedd58ae1 ("net: add gso_ipv4_max_size and gro_ipv4_max_size per device") > Reported-by: Xiumei Mu <xmu@redhat.com> > Signed-off-by: Xin Long <lucien.xin@gmail.com> Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 68a58d0a7b79..4c7d84072bd4 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2398,12 +2398,24 @@ 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]) { struct nlattr *af; int rem, err;
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 |grep gro_max_size dummy addrgenmode eui64 ... gro_max_size 4294967295 Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536") Fixes: 9eefedd58ae1 ("net: add gso_ipv4_max_size and gro_ipv4_max_size per device") Reported-by: Xiumei Mu <xmu@redhat.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/core/rtnetlink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)