From c5608c2c7e6c7ce02d702d18f215d4751f967963 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Fri, 28 Jan 2022 20:40:53 +0800 Subject: [PATCH] ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route stable inclusion from stable-v5.10.91 commit 48d5adb08d60116e9d05f01dcdbe698b5d54cdbb bugzilla: 186187 https://gitee.com/openeuler/kernel/issues/I4SI2C Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=48d5adb08d60116e9d05f01dcdbe698b5d54cdbb -------------------------------- 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 Signed-off-by: Chen Jun Signed-off-by: Zheng Zengkai --- net/ipv6/route.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 536cbc78ddbc..25745bce2c1f 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5342,7 +5342,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; } } -- GitLab