From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795621590; b=q513HFzO6hXOsGKoG6R96QPoc8iD8ozhpHWJeKM7NvQDWxsktLNwxu9iSPJV2i2hIZtR bSs6HTWjUKcQcWQmlE2K/832+0fwLnH52DHidJFilDo3lOgF7kygfoZtpg/sjVhE2koui ip6GCx+MwedXXUgi08bish/J1cSz6Q8Tk+0ZD2oDtHt7/88Pg5nv7NVkO49hOE6YX/n07 2SLITjfxGNtqbVy722kP/S/HPNmyIN7EMj71XA5ej2HNwTbj5Buluga+VxVFQTCzEcs/y OZW78xLC36PJZlEu0wQBoreKXgyViWSuC05NHKviGjDaNY/+fQHWg0y0XL9qkQOO7PA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795621590; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4Ld+QUMTEnbCJjG2pNZ5Gex1nMS6TkUsclgQfvGW5bM=; b=M8wmlch9dw6doT/QIqSIBDuOh9Dbj6wMQnnZJr+oEDZxa89FrgbfPiJMb64zEJyTJ1Uz EBP1iLUfjo97Vn2ckYKSQguufMI+sXGeMNCD3P57ubJxTmF3Skw1A36fvPyDqOlW0XYqP RvQlbllgBULI6zf5AWj+CTus6yxXJx+McKWbt+Zcuym/BiL6mnFm1RUJ4aLhJa/e0RDVs sHpn2NiUQt6eRU7DH7usta4TWztohsU1161GWwk0q2NAxWoSaUqER/p+yHg0ropIeRIkT ZK+D4FONl0mt71KBuZOfASwQvAYuCDqaYZhZUrc770NsrmfaOTar5xBKY+CuidKUyBw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=l8RtnNtT; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC67F606A32C; Wed, 25 Nov 2026 15:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=l8RtnNtT Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FF961F000C6; Wed, 25 Nov 2026 15:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795621590; bh=4Ld+QUMTEnbCJjG2pNZ5Gex1nMS6TkUsclgQfvGW5bM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l8RtnNtTEcTo5LhaGoncJ+C49IIRsZrkvA1KGBiGYFuLUkAl5kpMBDtK5vEcU/KkE tzHfVx7FYdJcB00ouJIwabJPzEF+2ZJUc2so5O24tpOftK66j5He500KK86a7BMSNW w42zb0UR6Bl3sFxYQQw3mzQ7ijnHrAqTV9rBXIag= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jason Zhang , Kuniyuki Iwashima , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 6.18 257/990] ipv6: Flush exception route while replacing nexthop. Date: Wed, 25 Nov 2026 15:27:04 +0100 Message-ID: <20261125143828.112172924@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143822.072087159@linuxfoundation.org> References: <20261125143822.072087159@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 9401b428b5d4dfe1fd5752973fd02b4e9cd05536 ] The following creates a cyclic reference between IPv6 route and nexthop: 1. create a nexthop A 2. create a nexthop group w/ A 3. create an IPv6 route with the nexthop group 4. create an exception route w/ A 5. replace A with a new nexthop B in the nexthop group 6. remove the IPv6 route 7. replace B with A in the nexthop group 8. remove the nexthop group Then, removing a device tied to the route gets stuck and triggers the splat below. [0] At 5., fib6_nh_release_dsts() is called, but it does not flush exception routes, so the nexthop A continues to grab the IPv6 route reference. nh_A->rt6i_exception_bucket[] -> rt6_ex->rt6i->from At 6., fib6_purge_rt() calls rt6_flush_exceptions(), but it only purges exceptions tied to nexthop B. Also, the route is unlinked from the nexthop group by list_del_init(&rt->nh_list). -> f6i->nh -> nhg->nh_entries[] At 8., __remove_nexthop_fib() cannot find the IPv6 route, and remove_nexthop_group() calls list_del_init(&nhge->nh_list) to unlink the group from the nexthop A's nhe->grp_list. nhg->nh_entries[] -> nh_A -> ... -> f6i Here, the nexthop A is reachable from net->nexthop.devhash[], but remove_nexthop_from_groups() cannot find the nexthop group, leaking the whole chain. Let's call fib6_nh_flush_exceptions() in fib6_nh_release_dsts(). [0]: unregister_netdevice: waiting for gre6 to become free. Usage count = 4 ref_tracker: netdev@000000009652f190 has 1/3 users at dst_alloc+0x14b/0x490 ip6_rt_cache_alloc+0x27b/0x670 __ip6_rt_update_pmtu+0x572/0x850 ip6_tnl_xmit+0x8c5/0x1b70 __gre6_xmit+0x7af/0xaa0 ip6gre_tunnel_xmit+0x685/0xdc0 dev_hard_start_xmit+0x204/0x5a0 __dev_queue_xmit+0xe8a/0x2550 ip6_finish_output+0x232/0x570 ip6_output+0x226/0x3b0 ip6_send_skb+0x133/0x250 rawv6_push_pending_frames+0x503/0x6f0 rawv6_sendmsg+0xdf0/0x1310 sock_sendmsg_nosec+0xde/0x130 __sys_sendto+0x27f/0x320 __x64_sys_sendto+0xd9/0xf0 Fixes: 7bf4796dd099 ("nexthops: add support for replace") Reported-by: Jason Zhang Signed-off-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20261101064418.2055158-2-kuniyu@google.com Reviewed-by: Ido Schimmel Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/route.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index af376b9568e2f..c11cf3c65c9f7 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3733,9 +3733,10 @@ void fib6_nh_release(struct fib6_nh *fib6_nh) { struct rt6_exception_bucket *bucket; + fib6_nh_release_dsts(fib6_nh); + rcu_read_lock(); - fib6_nh_flush_exceptions(fib6_nh, NULL); bucket = fib6_nh_get_excptn_bucket(fib6_nh, NULL); if (bucket) { rcu_assign_pointer(fib6_nh->rt6i_exception_bucket, NULL); @@ -3744,7 +3745,6 @@ void fib6_nh_release(struct fib6_nh *fib6_nh) rcu_read_unlock(); - fib6_nh_release_dsts(fib6_nh); free_percpu(fib6_nh->rt6i_pcpu); fib_nh_common_release(&fib6_nh->nh_common); @@ -3754,6 +3754,8 @@ void fib6_nh_release_dsts(struct fib6_nh *fib6_nh) { int cpu; + fib6_nh_flush_exceptions(fib6_nh, NULL); + if (!fib6_nh->rt6i_pcpu) return; -- 2.53.0