* [PATCH net v5] ipv6: addrconf: bail out of dad_failure when state is no longer POSTDAD
@ 2026-05-13 2:55 Linmao Li
2026-05-14 6:41 ` Ido Schimmel
0 siblings, 1 reply; 2+ messages in thread
From: Linmao Li @ 2026-05-13 2:55 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet
Cc: dsahern, horms, stephen, hannes, sd, idosch, netdev, linux-kernel,
Linmao Li
addrconf_dad_failure() transitions ifp->state from DAD to POSTDAD
via addrconf_dad_end(), which drops ifp->lock on return. The lock
is re-acquired after net_info_ratelimited(). A concurrent
ipv6_del_addr() can take the lock in that window, set ifp->state
to DEAD and run list_del_rcu(&ifp->if_list).
addrconf_dad_failure() then overwrites DEAD with ERRDAD at errdad:
and schedules a new dad_work. The work calls ipv6_del_addr()
again, hitting the already-poisoned list entry:
general protection fault: 0000 [#1] SMP NOPTI
CPU: 4 PID: 217 Comm: kworker/4:1
Workqueue: ipv6_addrconf addrconf_dad_work
RIP: 0010:ipv6_del_addr+0xe9/0x280
RAX: dead000000000122
Call Trace:
addrconf_dad_stop+0x113/0x140
addrconf_dad_work+0x28c/0x430
process_one_work+0x1eb/0x3b0
worker_thread+0x4d/0x400
kthread+0x104/0x140
ret_from_fork+0x35/0x40
Fold the addrconf_dad_end() logic into addrconf_dad_failure() under
a single ifp->lock critical section. The STABLE_PRIVACY branch
temporarily drops ifp->lock around address regeneration, so at
lock_errdad: verify the state is still POSTDAD before transitioning
to ERRDAD; bail out otherwise to avoid overwriting a state set by
another path while the lock was released.
Fixes: c15b1ccadb32 ("ipv6: move DAD and addrconf_verify processing to workqueue")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
v5: At lock_errdad, check for any state other than POSTDAD instead of
only DEAD, to avoid overwriting a state set while the lock was
released (suggested by Ido Schimmel).
Update subject and last commit message paragraph accordingly.
v4: Move the bail-out from errdad: to right after lock_errdad:
re-acquires ifp->lock, since DAD failure path needs the
state transition to ERRDAD (suggested by Paolo Abeni).
v3: Fold addrconf_dad_end() into addrconf_dad_failure() under a
single ifp->lock critical section, instead of adding a check
at errdad: with a racy state inspection (suggested by Sabrina
Dubroca).
v2: Add Fixes: tag.
v1: https://lore.kernel.org/netdev/20260420032842.1063277-1-lilinmao@kylinos.cn/
net/ipv6/addrconf.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 5476b6536eb7..da0f07e21e3f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2166,16 +2166,18 @@ void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp)
struct net *net = dev_net(idev->dev);
int max_addresses;
- if (addrconf_dad_end(ifp)) {
+ spin_lock_bh(&ifp->lock);
+
+ if (ifp->state != INET6_IFADDR_STATE_DAD) {
+ spin_unlock_bh(&ifp->lock);
in6_ifa_put(ifp);
return;
}
+ ifp->state = INET6_IFADDR_STATE_POSTDAD;
net_info_ratelimited("%s: IPv6 duplicate address %pI6c used by %pM detected!\n",
ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source);
- spin_lock_bh(&ifp->lock);
-
if (ifp->flags & IFA_F_STABLE_PRIVACY) {
struct in6_addr new_addr;
struct inet6_ifaddr *ifp2;
@@ -2223,6 +2225,11 @@ void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp)
in6_ifa_put(ifp2);
lock_errdad:
spin_lock_bh(&ifp->lock);
+ if (ifp->state != INET6_IFADDR_STATE_POSTDAD) {
+ spin_unlock_bh(&ifp->lock);
+ in6_ifa_put(ifp);
+ return;
+ }
}
errdad:
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net v5] ipv6: addrconf: bail out of dad_failure when state is no longer POSTDAD
2026-05-13 2:55 [PATCH net v5] ipv6: addrconf: bail out of dad_failure when state is no longer POSTDAD Linmao Li
@ 2026-05-14 6:41 ` Ido Schimmel
0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2026-05-14 6:41 UTC (permalink / raw)
To: Linmao Li
Cc: davem, kuba, pabeni, edumazet, dsahern, horms, stephen, hannes,
sd, netdev, linux-kernel
On Wed, May 13, 2026 at 10:55:09AM +0800, Linmao Li wrote:
> addrconf_dad_failure() transitions ifp->state from DAD to POSTDAD
> via addrconf_dad_end(), which drops ifp->lock on return. The lock
> is re-acquired after net_info_ratelimited(). A concurrent
> ipv6_del_addr() can take the lock in that window, set ifp->state
> to DEAD and run list_del_rcu(&ifp->if_list).
>
> addrconf_dad_failure() then overwrites DEAD with ERRDAD at errdad:
> and schedules a new dad_work. The work calls ipv6_del_addr()
> again, hitting the already-poisoned list entry:
>
> general protection fault: 0000 [#1] SMP NOPTI
> CPU: 4 PID: 217 Comm: kworker/4:1
> Workqueue: ipv6_addrconf addrconf_dad_work
> RIP: 0010:ipv6_del_addr+0xe9/0x280
> RAX: dead000000000122
> Call Trace:
> addrconf_dad_stop+0x113/0x140
> addrconf_dad_work+0x28c/0x430
> process_one_work+0x1eb/0x3b0
> worker_thread+0x4d/0x400
> kthread+0x104/0x140
> ret_from_fork+0x35/0x40
>
> Fold the addrconf_dad_end() logic into addrconf_dad_failure() under
> a single ifp->lock critical section. The STABLE_PRIVACY branch
> temporarily drops ifp->lock around address regeneration, so at
> lock_errdad: verify the state is still POSTDAD before transitioning
> to ERRDAD; bail out otherwise to avoid overwriting a state set by
> another path while the lock was released.
>
> Fixes: c15b1ccadb32 ("ipv6: move DAD and addrconf_verify processing to workqueue")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-14 6:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 2:55 [PATCH net v5] ipv6: addrconf: bail out of dad_failure when state is no longer POSTDAD Linmao Li
2026-05-14 6:41 ` Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox