* [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add()
@ 2025-08-04 20:42 Maksimilijan Marosevic
2025-08-05 16:16 ` David Ahern
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Maksimilijan Marosevic @ 2025-08-04 20:42 UTC (permalink / raw)
To: davem, dsahern
Cc: netdev, linux-kernel, linux-kernel-mentees,
Maksimilijan Marosevic, syzbot+a259a17220263c2d73fc
This check was removed in commit e6f497955fb6 ("ipv6: Check GATEWAY
in rtm_to_fib6_multipath_config().") as part of rt6_qualify_for ecmp().
The author correctly recognises that rt6_qualify_for_ecmp() returns
false if fb_nh_gw_family is set to AF_UNSPEC, but then mistakes
AF_UNSPEC for AF_INET6 when reasoning that the check is unnecessary.
This means certain malformed entries don't get caught in
ip6_route_multipath_add().
This patch reintroduces the AF_UNSPEC check while respecting changes
of the initial patch.
Reported-by: syzbot+a259a17220263c2d73fc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a259a17220263c2d73fc
Fixes: e6f497955fb6 ("ipv6: Check GATEWAY in rtm_to_fib6_multipath_config().")
Signed-off-by: Maksimilijan Marosevic <maksimilijan.marosevic@proton.me>
---
net/ipv6/route.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3299cfa12e21..d4b988bed920 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5456,6 +5456,14 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
goto cleanup;
}
+ if (rt->fib6_nh->fib_nh_gw_family == AF_UNSPEC) {
+ err = -EINVAL;
+ NL_SET_ERR_MSG(extack,
+ "Device only routes can not be added for IPv6 using the multipath API.");
+ fib6_info_release(rt);
+ goto cleanup;
+ }
+
rt->fib6_nh->fib_nh_weight = rtnh->rtnh_hops + 1;
err = ip6_route_info_append(&rt6_nh_list, rt, &r_cfg);
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add()
2025-08-04 20:42 [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add() Maksimilijan Marosevic
@ 2025-08-05 16:16 ` David Ahern
2025-08-12 8:16 ` Paolo Abeni
2025-09-04 16:03 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2025-08-05 16:16 UTC (permalink / raw)
To: Maksimilijan Marosevic, davem
Cc: netdev, linux-kernel, linux-kernel-mentees,
syzbot+a259a17220263c2d73fc
On 8/4/25 2:42 PM, Maksimilijan Marosevic wrote:
> This check was removed in commit e6f497955fb6 ("ipv6: Check GATEWAY
> in rtm_to_fib6_multipath_config().") as part of rt6_qualify_for ecmp().
> The author correctly recognises that rt6_qualify_for_ecmp() returns
> false if fb_nh_gw_family is set to AF_UNSPEC, but then mistakes
> AF_UNSPEC for AF_INET6 when reasoning that the check is unnecessary.
> This means certain malformed entries don't get caught in
> ip6_route_multipath_add().
>
> This patch reintroduces the AF_UNSPEC check while respecting changes
> of the initial patch.
>
> Reported-by: syzbot+a259a17220263c2d73fc@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a259a17220263c2d73fc
> Fixes: e6f497955fb6 ("ipv6: Check GATEWAY in rtm_to_fib6_multipath_config().")
> Signed-off-by: Maksimilijan Marosevic <maksimilijan.marosevic@proton.me>
> ---
> net/ipv6/route.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 3299cfa12e21..d4b988bed920 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -5456,6 +5456,14 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
> goto cleanup;
> }
>
> + if (rt->fib6_nh->fib_nh_gw_family == AF_UNSPEC) {
> + err = -EINVAL;
> + NL_SET_ERR_MSG(extack,
> + "Device only routes can not be added for IPv6 using the multipath API.");
> + fib6_info_release(rt);
> + goto cleanup;
> + }
> +
> rt->fib6_nh->fib_nh_weight = rtnh->rtnh_hops + 1;
>
> err = ip6_route_info_append(&rt6_nh_list, rt, &r_cfg);
can you add another test to the routing selftests to cover this case?
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add()
2025-08-04 20:42 [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add() Maksimilijan Marosevic
2025-08-05 16:16 ` David Ahern
@ 2025-08-12 8:16 ` Paolo Abeni
2025-09-04 16:03 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2025-08-12 8:16 UTC (permalink / raw)
To: Maksimilijan Marosevic, davem, dsahern
Cc: netdev, linux-kernel, linux-kernel-mentees,
syzbot+a259a17220263c2d73fc
On 8/4/25 10:42 PM, Maksimilijan Marosevic wrote:
> This check was removed in commit e6f497955fb6 ("ipv6: Check GATEWAY
> in rtm_to_fib6_multipath_config().") as part of rt6_qualify_for ecmp().
> The author correctly recognises that rt6_qualify_for_ecmp() returns
> false if fb_nh_gw_family is set to AF_UNSPEC, but then mistakes
> AF_UNSPEC for AF_INET6 when reasoning that the check is unnecessary.
> This means certain malformed entries don't get caught in
> ip6_route_multipath_add().
>
> This patch reintroduces the AF_UNSPEC check while respecting changes
> of the initial patch.
>
> Reported-by: syzbot+a259a17220263c2d73fc@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a259a17220263c2d73fc
> Fixes: e6f497955fb6 ("ipv6: Check GATEWAY in rtm_to_fib6_multipath_config().")
> Signed-off-by: Maksimilijan Marosevic <maksimilijan.marosevic@proton.me>
Please resend in a 2 patches series including an additional self-test as
asked by David.
Also please insert into the subj prefix the target tree ('net' in this
case) and add Kuniyuki into the CC list.
Thanks,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add()
2025-08-04 20:42 [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add() Maksimilijan Marosevic
2025-08-05 16:16 ` David Ahern
2025-08-12 8:16 ` Paolo Abeni
@ 2025-09-04 16:03 ` Jakub Kicinski
2025-09-05 22:12 ` Maksimilijan Marošević
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-09-04 16:03 UTC (permalink / raw)
To: Maksimilijan Marosevic
Cc: davem, dsahern, netdev, linux-kernel, linux-kernel-mentees,
syzbot+a259a17220263c2d73fc
On Mon, 04 Aug 2025 20:42:53 +0000 Maksimilijan Marosevic wrote:
> This check was removed in commit e6f497955fb6 ("ipv6: Check GATEWAY
> in rtm_to_fib6_multipath_config().") as part of rt6_qualify_for ecmp().
> The author correctly recognises that rt6_qualify_for_ecmp() returns
> false if fb_nh_gw_family is set to AF_UNSPEC, but then mistakes
> AF_UNSPEC for AF_INET6 when reasoning that the check is unnecessary.
> This means certain malformed entries don't get caught in
> ip6_route_multipath_add().
>
> This patch reintroduces the AF_UNSPEC check while respecting changes
> of the initial patch.
Hi Maksimilijan!
Are you planning to repost this with a test?
If not I suppose we can enlist the author of the commit to help with
the selftest..
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add()
2025-09-04 16:03 ` Jakub Kicinski
@ 2025-09-05 22:12 ` Maksimilijan Marošević
0 siblings, 0 replies; 5+ messages in thread
From: Maksimilijan Marošević @ 2025-09-05 22:12 UTC (permalink / raw)
To: kuba@kernel.org
Cc: davem@davemloft.net, dsahern@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+a259a17220263c2d73fc@syzkaller.appspotmail.com
Hi Jakub,
Sorry for the delay.
I've managed to devise a test-case that reliably reproduces the error, but I now believe the fix can be implemented better. Unfortunately, I haven't had the chance to work on the new fix these past couple of weeks.
I'll try to finish it this weekend and then run it through syzbot once more.
Maksimilijan
-------- Original Message --------
On 04/09/2025 18:03, Jakub Kicinski <kuba@kernel.org> wrote:
> On Mon, 04 Aug 2025 20:42:53 +0000 Maksimilijan Marosevic wrote:
> > This check was removed in commit e6f497955fb6 ("ipv6: Check GATEWAY
> > in rtm_to_fib6_multipath_config().") as part of rt6_qualify_for ecmp().
> > The author correctly recognises that rt6_qualify_for_ecmp() returns
> > false if fb_nh_gw_family is set to AF_UNSPEC, but then mistakes
> > AF_UNSPEC for AF_INET6 when reasoning that the check is unnecessary.
> > This means certain malformed entries don't get caught in
> > ip6_route_multipath_add().
> >
> > This patch reintroduces the AF_UNSPEC check while respecting changes
> > of the initial patch.
>
> Hi Maksimilijan!
>
> Are you planning to repost this with a test?
> If not I suppose we can enlist the author of the commit to help with
> the selftest..
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-05 22:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 20:42 [PATCH 1/1] ipv6: Check AF_UNSPEC in ip6_route_multipath_add() Maksimilijan Marosevic
2025-08-05 16:16 ` David Ahern
2025-08-12 8:16 ` Paolo Abeni
2025-09-04 16:03 ` Jakub Kicinski
2025-09-05 22:12 ` Maksimilijan Marošević
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox