ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route
authorDavid Ahern <dsahern@kernel.org>
Fri, 31 Dec 2021 00:36:34 +0000 (17:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jan 2022 14:23:32 +0000 (15:23 +0100)
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 <dsahern@kernel.org>
Cc: Roopa Prabhu <roopa@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/route.c

index b6bbab05eb9483eafa124de36867ee59aa4911c7..e34cb4db6eb11dea1451d3a0afa78cdc508a9d6f 100644 (file)
@@ -5307,7 +5307,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;
                        }
                }