All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: netdev-bot+sashiko@kernel.org
Cc: 4ncienth@gmail.com, dsahern@kernel.org, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/3] ipv6: serialize address publication with device teardown
Date: Mon, 12 Oct 2026 18:13:16 +0300	[thread overview]
Message-ID: <20261012151316.GA798355@shredder> (raw)
In-Reply-To: <179161099408.434549.14449036924552933828@kernel.org>

On Sat, Oct 10, 2026 at 05:43:14AM +0000, netdev-bot+sashiko@kernel.org wrote:
> [Severity: High]
> This is a pre-existing issue and was not introduced by this patch. The
> recheck above does not cover the window after ipv6_add_addr() returns to
> addrconf_dad_failure().
> 
> addrconf_dad_failure() runs from ndisc_recv_ns()/ndisc_recv_na() in
> softirq without RTNL. For IFA_F_STABLE_PRIVACY addresses it does:
> 
> net/ipv6/addrconf.c:addrconf_dad_failure() {
>     ...
> 		ifp2 = ipv6_add_addr(idev, &cfg, false, NULL);
> 		if (IS_ERR(ifp2))
> 			goto lock_errdad;
> 
> 		spin_lock_bh(&ifp2->lock);
> 		ifp2->stable_privacy_retry = retries;
> 		ifp2->state = INET6_IFADDR_STATE_PREDAD;
> 		spin_unlock_bh(&ifp2->lock);
> 
> 		addrconf_mod_dad_work(ifp2, net->ipv6.sysctl.idgen_delay);
>     ...
> }
> 
> addrconf_ifdown() can run on another CPU because of NETDEV_DOWN,
> disable_ipv6, or NETDEV_CHANGEMTU below IPV6_MIN_MTU. If it snapshots
> addr_list after ifp2 is linked, it can tear ifp2 down completely before
> the spin_lock_bh(&ifp2->lock) above:
> 
> CPU1 (addrconf_ifdown)
>     ifa->state = INET6_IFADDR_STATE_DEAD;
>     __ipv6_ifa_notify(RTM_DELADDR, ifa)
>         ip6_del_rt(net, ifp->rt, false);
>         ifp->rt = NULL;
>     list_del_rcu(&ifa->if_list);
>     in6_ifa_put(ifa);
> 
> CPU2 (addrconf_dad_failure)
>     ifp2->state = INET6_IFADDR_STATE_PREDAD;
>     addrconf_mod_dad_work(ifp2, ...);
> 
> Can CPU2 overwrite the DEAD state here and queue DAD work on an address
> that has already been torn down?
> 
> Suppose IF_READY is still set and ifp2 has inherited IFA_F_OPTIMISTIC.
> Then addrconf_dad_work()->addrconf_dad_begin() reaches:
> 
> 	if (ifp->flags & IFA_F_OPTIMISTIC) {
> 		ip6_ins_rt(net, ifp->rt);
> 
> At this point ifp->rt is NULL, and __ip6_ins_rt() dereferences
> rt->fib6_table. IF_READY stays set in two cases:
> 
> - the NETDEV_CHANGEMTU path calls addrconf_ifdown(dev, true) without a
>   prior NETDEV_DOWN
> - the link comes back up within idgen_delay
> 
> Otherwise the address is left in state DAD or POSTDAD. On the final put,
> inet6_ifa_finish_destroy() then hits:
> 
> 	if (ifp->state != INET6_IFADDR_STATE_DEAD) {
> 		pr_warn("Freeing alive inet6 address %p\n", ifp);
> 		return;
> 	}
> 
> so the ifaddr is never freed.
> 
> addrconf_dad_start() avoids this by checking for DEAD first:
> 
> 	if (ifp->state != INET6_IFADDR_STATE_DEAD) {
> 		ifp->state = INET6_IFADDR_STATE_PREDAD;
> 		begin_dad = true;
> 	}
> 
> Would a similar check under ifp2->lock in addrconf_dad_failure() work?
> The PREDAD write itself looks redundant, because ipv6_add_addr() already
> returns the object in state 0 (PREDAD). No later patch in this series
> changes addrconf_dad_failure().

Looks like a valid issue. Please fix in patch #4 in v4 with something
like this:

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7bd0e8820abb..7cb156ddc191 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2230,7 +2230,6 @@ void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp)
 
 		spin_lock_bh(&ifp2->lock);
 		ifp2->stable_privacy_retry = retries;
-		ifp2->state = INET6_IFADDR_STATE_PREDAD;
 		spin_unlock_bh(&ifp2->lock);
 
 		addrconf_mod_dad_work(ifp2, net->ipv6.sysctl.idgen_delay);


  reply	other threads:[~2026-10-12 15:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  5:40 [PATCH net v3 0/3] ipv6: fix address publication races with addrconf_ifdown Daehyeon Ko
2026-10-09  5:40 ` [PATCH net v3 1/3] ipv6: serialize address publication with device teardown Daehyeon Ko
2026-10-10  5:43   ` netdev-bot+sashiko
2026-10-12 15:13     ` Ido Schimmel [this message]
2026-10-12 14:53   ` Ido Schimmel
2026-10-09  5:40 ` [PATCH net v3 2/3] ipv6: remove ifaddr from hash during ifdown list cleanup Daehyeon Ko
2026-10-10  5:43   ` netdev-bot+sashiko
2026-10-09  5:40 ` [PATCH net v3 3/3] ipv6: initialize temporary ifaddr before publication Daehyeon Ko
2026-10-10  5:43   ` netdev-bot+sashiko
2026-10-12 14:52     ` Ido Schimmel
2026-10-09  5:44 ` [PATCH net v3 0/3] ipv6: fix address publication races with addrconf_ifdown netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261012151316.GA798355@shredder \
    --to=idosch@nvidia.com \
    --cc=4ncienth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.