diff mbox series

[net,4/5] ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route

Message ID 20211231003635.91219-5-dsahern@kernel.org (mailing list archive)
State Accepted
Commit 1ff15a710a862db1101b97810af14aedc835a86a
Delegated to: Netdev Maintainers
Headers show
Series net: Length checks for attributes within multipath routes | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers fail 4 blamed authors not CCed: nicolas.dichtel@6wind.com roopa@cumulusnetworks.com davem@davemloft.net nikolay@cumulusnetworks.com; 6 maintainers not CCed: kuba@kernel.org nikolay@cumulusnetworks.com roopa@cumulusnetworks.com nicolas.dichtel@6wind.com yoshfuji@linux-ipv6.org davem@davemloft.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

David Ahern Dec. 31, 2021, 12:36 a.m. UTC
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>
---
 net/ipv6/route.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Nicolas Dichtel Dec. 31, 2021, 3:51 p.m. UTC | #1
Le 31/12/2021 à 01:36, David Ahern a écrit :
> 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>
> ---
>  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 d16599c225b8..b311c0bc9983 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -5453,7 +5453,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;
When ip6_route_del() fails, the loop continue. For consistency, maybr it could
be good to do the same for this error.
diff mbox series

Patch

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d16599c225b8..b311c0bc9983 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5453,7 +5453,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;
 			}
 		}