From: David Ahern Date: Fri, 31 Dec 2021 00:36:34 +0000 (-0700) Subject: ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route X-Git-Tag: v4.19.225~13 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e30dead00aaa5a575b10117dad8edc126efc1873;p=users%2Fdwmw2%2Flinux.git ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route commit 1ff15a710a862db1101b97810af14aedc835a86a upstream. Make sure RTA_GATEWAY for IPv6 multipath route has enough bytes to hold an IPv6 address. Fixes: 6b9ea5a64ed5 ("ipv6: fix multipath route replace error recovery") Signed-off-by: David Ahern Cc: Roopa Prabhu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 9df115e89f6ca..1bc81be07ccda 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4606,7 +4606,11 @@ static int ip6_route_multipath_del(struct fib6_config *cfg, nla = nla_find(attrs, attrlen, RTA_GATEWAY); if (nla) { - nla_memcpy(&r_cfg.fc_gateway, nla, 16); + err = fib6_gw_from_attr(&r_cfg.fc_gateway, nla, + extack); + if (err) + return err; + r_cfg.fc_flags |= RTF_GATEWAY; } }