From nobody Fri Jun 12 19:58:08 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C0923644BC; Wed, 13 May 2026 02:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778640924; cv=none; b=bwSmkKUTChrKZT4mH6tF7hn1NXtEilFV48d8S35jlcHMRlhrlmmGzXx2Mm/2+jWf5o1kLlibRzESbANfMzo5s8Ge6r9Y3dDpsCZN4sL8fsiTCv/lqyQw89deaawyJnXSOznsG/yxGtcUx0tGvVEM6Q1rNPmTYCp/UYjku4jgm/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778640924; c=relaxed/simple; bh=aq13JdKIuxoMJvQDfMt8wOUWXEVFtqSFnOiPBB1S9Wg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=RPaju1X1XCVtAWeu7k4nLci6jBpengJvMbdSfv0ZUVt9vmfZmkjJoH8fHU3ZxXIZu2IHeYql+WN14oHc7mutqEGq/OHgiKMAtcWXFOc98HeKY3LvBBUTh9NrF9dVtTERExOYltxpa/9X88lDGec7xKPBWNfWm3RH8vuGRQCCfao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 2a6cc6ee4e7711f1aa26b74ffac11d73-20260513 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:0f046f72-62af-4b30-900c-917c6fa65b6b,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:3d93ea3362334b4bdae3a37af6828aa5,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|898,TC:nil,Content:0|15|50,EDM:- 3,IP:nil,URL:99|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA: 0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_ULS,TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 2a6cc6ee4e7711f1aa26b74ffac11d73-20260513 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 742152211; Wed, 13 May 2026 10:55:14 +0800 From: Linmao Li To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com Cc: dsahern@kernel.org, horms@kernel.org, stephen@networkplumber.org, hannes@stressinduktion.org, sd@queasysnail.net, idosch@nvidia.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linmao Li Subject: [PATCH net v5] ipv6: addrconf: bail out of dad_failure when state is no longer POSTDAD Date: Wed, 13 May 2026 10:55:09 +0800 Message-Id: <20260513025509.3776405-1-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 work= queue") Signed-off-by: Linmao Li Reviewed-by: Ido Schimmel --- 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@kylino= s.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, stru= ct inet6_ifaddr *ifp) struct net *net =3D dev_net(idev->dev); int max_addresses; =20 - if (addrconf_dad_end(ifp)) { + spin_lock_bh(&ifp->lock); + + if (ifp->state !=3D INET6_IFADDR_STATE_DAD) { + spin_unlock_bh(&ifp->lock); in6_ifa_put(ifp); return; } + ifp->state =3D INET6_IFADDR_STATE_POSTDAD; =20 net_info_ratelimited("%s: IPv6 duplicate address %pI6c used by %pM detect= ed!\n", ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source); =20 - 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, struc= t inet6_ifaddr *ifp) in6_ifa_put(ifp2); lock_errdad: spin_lock_bh(&ifp->lock); + if (ifp->state !=3D INET6_IFADDR_STATE_POSTDAD) { + spin_unlock_bh(&ifp->lock); + in6_ifa_put(ifp); + return; + } } =20 errdad: --=20 2.25.1