When an interface MTU drops below IPV6_MIN_MTU, addrconf_notify() stops IPv6 on the interface via addrconf_ifdown(). With keep_addr_on_down enabled, permanent addresses are kept but their host routes are deleted and ifp->rt is cleared; recovery is expected to happen when the device is brought up, where the NETDEV_UP path runs addrconf_permanent_addr(). That recovery never happens when IPv6 is stopped through the NETDEV_CHANGEMTU path: the device itself never goes down, so no NETDEV_UP event follows when the MTU is restored. The address is left with ifp->rt == NULL while the device is up, and every later RTM_NEWADDR notification only warns: BUG: Address ::ffff:127.0.0.1 on device lo is missing its host route. syzbot hit this by flapping lo's MTU across IPV6_MIN_MTU with keep_addr_on_down set and toggling IFF_NOARP, which restarts DAD; DAD is skipped on the loopback device, so DAD completion and the warning repeat on every toggle and the address stays permanently without its host route. Instead of only warning, regenerate the host route with fixup_permanent_addr() when RTM_NEWADDR arrives for an address without ifp->rt on an up device, keeping the warning only for the allocation failure case. Fixes: 2d819d250a13 ("ipv6: Handle missing host route in __ipv6_ifa_notify") Reported-by: syzbot+af16ddc8fd22a1d135f8@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=af16ddc8fd22a1d135f8 Signed-off-by: Shuai Liu <847807867@qq.com> --- net/ipv6/addrconf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 4b0cb7d23541d..70230ffdc077f 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -6357,17 +6357,17 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) /* * If the address was optimistic we inserted the route at the * start of our DAD process, so we don't need to do it again. - * If the device was taken down in the middle of the DAD - * cycle there is a race where we could get here without a - * host route, so nothing to insert. That will be fixed when - * the device is brought up. + * Otherwise, if the host route is gone while the device is up + * (e.g. dropped by addrconf_ifdown() for a low MTU and the + * address kept by keep_addr_on_down), regenerate it. */ - if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) { - ip6_ins_rt(net, ifp->rt); - } else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) { - pr_warn("BUG: Address %pI6c on device %s is missing its host route.\n", - &ifp->addr, ifp->idev->dev->name); + if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) { + if (fixup_permanent_addr(net, ifp->idev, ifp)) + pr_warn("BUG: Address %pI6c on device %s is missing its host route.\n", + &ifp->addr, ifp->idev->dev->name); } + if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) + ip6_ins_rt(net, ifp->rt); if (ifp->idev->cnf.forwarding) addrconf_join_anycast(ifp); base-commit: 7cfbf79c66c63e807ea452abf0546e6f6d6833a6 -- 2.43.0