From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6155E2236E3 for ; Thu, 25 Jun 2026 04:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782362471; cv=none; b=VkXfBg/ijRC40hfXoxfDC+mCuNVnp3ImYLfCuA8q4niPtbEhsk84WUFErANxIbvfx74uItnRZ0mdE9S680rm7jVC/NQwQPDQHM3Q1gLAy/lG4xXPQilC94CqJ+61zkPfZKrnq4dvuXRRAefynm7zAnRI73KUYvAheNZUYN8ZR+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782362471; c=relaxed/simple; bh=T9SXqfsO/EFq+dYj0i1JvBToxhsvtWDwvs2JRGi+kgM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qvPPTxthjus8BrHhTPrT0KgLpqLkroYg+esdCLIX8VB0sKwLH20d/BgAEQrqCva5hv2xpU0cMQ8OGeTxXFwICxQb6F8rvWsFWbIOqlCi0h6t4uZoGQUI9oWVntPF6ZOsXaZ74TqrC7l4p1g3SbTnf+BdfiiO1MmBFHYaDZoA5jk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iu+3Fx8c; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iu+3Fx8c" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-37df9f1ee33so76021a91.3 for ; Wed, 24 Jun 2026 21:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782362468; x=1782967268; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XWrI8sitTaDcWEaHG+ZnIRCNC7VJeTwjUrHgR3uWgo8=; b=iu+3Fx8coAKV5knhsLFROxTWx0fLwI0N/ouJgZEzDtLv9DIVB9iBq3IXQuzaGoADW8 5FO86ON8sozd14NygaxVmx+i6fOp/GkaUgWQfqbf4GWF3YAz+7O1VtLUFVi754dG9+GD SDtWmu+ZlZjSW9hqIxWQZHy4wG+aVDKEQgkXNnJzE63T+owMTHYfanxbA06gYMUPtur2 WLdKkKLJQbKLExVd8ic4nYjSEAG7QLv7Tr7cJ+19dcvMWxQHeOUjYQLDzcZdLREuKBuR UkORohXuwndO5GmaKNN/4LZw8dTSVyidMbOoC1h/COHzf+SSw7hwHBN+k22F8jhT37fX RXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782362468; x=1782967268; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XWrI8sitTaDcWEaHG+ZnIRCNC7VJeTwjUrHgR3uWgo8=; b=tWumphPtknENeqxISIBhcNgKcjJzPgD52z0AnbcJIPd9GQsmxeZpBRsz4SPdbCMl/+ BggpeCwDqWL9zyc8F7CByxLiXPYhne/famASR4F0AYWDZVfJkFNPVqMyHW1eOlEiiWYP Vja/ts0QaJT8hgrLA8VIoQJYeLCN4VIlWDfEoYQe5NWjO67MynYohtrXR4aXUGJaDgjn tQjqSZmDz4Rv1Xj577EMztcE4qwZ8+w1+rp/Q6ZhjwF1kTSaxG9p82Retcw8u/N0L+/m BOTC8gA10Ki1bHzllnlPGBTFVB0EuoR29ue5a0IORP9CzRsiMoYRzZMPxKN1TZ2Z6BB0 fe8A== X-Forwarded-Encrypted: i=1; AHgh+RrYDH9mCoQy5N0swX0rUK5VH20TDIc6N1WrwtIlMYeYHek4GQjyWvdIobQVu4VDgbZUYYjY6wVrATr5+gs=@vger.kernel.org X-Gm-Message-State: AOJu0YwhxhWt6nwDGoQ6gjg/+NHVVr1XSGJr5L1GAJWA+/dcdCgKSFQt 5p+ACDHiNvstEC1iniASS32sGrrJaHCGP2ASztqoOvZwVTeI0AI/e8+R X-Gm-Gg: AfdE7cmnvuM6Eh7LU4UhGLKSVdKGZE+quu07Rq4PJ5UGGSA8DN/u5bYnabyWNIwPt2H 998mStm6d4ZryJ5MzOqgbZXPzlnvFySpmaFpsGs3IJ2OvYIsu92U2aCo9W5/+3468ZjtAMGC7+S 8hrYdzLOWirhDWgkpqcBU3TByNoTEk3Ir+jFpIhTGAiSXlPst+ceabXW+mX9l2VlDNwQv7LqzrS pvzltEGMgzmfPugNcHvL2OBx8I6WSLYfRCvAocui7nmIWQirxn2KufVXj9SDezgI1Y58Yr1ufgV 2Iy/CsGuaVC/tXd3G+O/l9rUGqHNm26lYinvofQ14mv1Bj5KYbMH1Pc0G2qZs4pECbcbXjmsjHJ ba+b1gkxV1xdicWLIa50TWzKIdbMD31+IgNEBm0BgcLShvv/RaMJ/5h0Ub6hZ8uB8LwznAZWigL Dw+Fx8Qn6SkZbLj3FvTwIo7k7EL+M= X-Received: by 2002:a17:90b:50cc:b0:37c:60da:a9f3 with SMTP id 98e67ed59e1d1-37dfa263e84mr833019a91.20.1782362468449; Wed, 24 Jun 2026 21:41:08 -0700 (PDT) Received: from online.mioffice.cn ([43.224.245.228]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c92b96ec739sm887723a12.2.2026.06.24.21.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 21:41:07 -0700 (PDT) From: Pengfei Zhang To: dsahern@kernel.org, idosch@nvidia.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, chenzhangqi@xiaomi.com, baohua@kernel.org, Pengfei Zhang , Pengfei Zhang Subject: [PATCH v2 net] ipv6: fib6: fix NULL deref in fib6_walk_continue() on multi-batch dump Date: Thu, 25 Jun 2026 12:41:01 +0800 Message-Id: <20260625044101.939070-1-zhangfeionline@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Pengfei Zhang inet6_dump_fib() saves its progress in cb->args[1] as a positional index within the current hash chain. Between batches the RTNL lock is released, so a concurrent fib6_new_table() can insert a new table at the chain head, shifting all existing entries. The saved index then lands on a different table, causing fib6_dump_table() to set w->root to the wrong table while w->node still points into the previous one. fib6_walk_continue() dereferences w->node->parent (NULL) and panics: BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:fib6_walk_continue+0x6e/0x170 Call Trace: fib6_dump_table.isra.0+0xc5/0x240 inet6_dump_fib+0xf6/0x420 rtnl_dumpit+0x30/0xa0 netlink_dump+0x15b/0x460 netlink_recvmsg+0x1d6/0x2a0 ____sys_recvmsg+0x17a/0x190 Fix by storing tb->tb6_id in cb->args[1] instead of a positional index. On resume, skip entries until the id matches; a concurrent head-insert can never match the saved id, so the walker always resumes on the correct table. Fixes: 1b43af5480c3 ("[IPV6]: Increase number of possible routing tables to 2^32") Signed-off-by: Pengfei Zhang --- net/ipv6/ip6_fib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index fc95738de..bda492634 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -636,11 +636,11 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) }; const struct nlmsghdr *nlh = cb->nlh; struct net *net = sock_net(skb->sk); - unsigned int e = 0, s_e; struct hlist_head *head; struct fib6_walker *w; struct fib6_table *tb; unsigned int h, s_h; + u32 s_id; int err = 0; rcu_read_lock(); @@ -701,23 +701,22 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) } s_h = cb->args[0]; - s_e = cb->args[1]; + s_id = cb->args[1]; - for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_e = 0) { - e = 0; + for (h = s_h; h < FIB6_TABLE_HASHSZ; h++, s_id = 0) { head = &net->ipv6.fib_table_hash[h]; hlist_for_each_entry_rcu(tb, head, tb6_hlist) { - if (e < s_e) - goto next; + if (s_id && tb->tb6_id != s_id) + continue; + s_id = 0; + + cb->args[1] = tb->tb6_id; err = fib6_dump_table(tb, skb, cb); if (err != 0) goto out; -next: - e++; } } out: - cb->args[1] = e; cb->args[0] = h; unlock: -- 2.34.1