From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 D9EDC256D for ; Thu, 25 Jun 2026 01:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782350612; cv=none; b=q/WN5RYxoCcLS+KRkAjoMJt9voIsA/Mdd6poD62tukfdZeFlQuWHPRgYV8yGbiTr8d1U9MUhD3tvtpLiUMIfn6cX+iHGlqNHPkJJG78mYRO7YfhGmDnSeiWk042wQj/8qounGOwPJNBldCzCJQQX1Ft9roadcehoFwDLl3gG58M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782350612; c=relaxed/simple; bh=T9SXqfsO/EFq+dYj0i1JvBToxhsvtWDwvs2JRGi+kgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dDUuVaoW0tWDHSV+NiV5Bro2x0yOi3SfWmWUblO8IcTA4eefqK5P55Hm5D0izL1DGNPkfQYHrku7pwLuiS+8T7LSIfuNzQVGVIKnvSy8d1mdtTRMqcZC4vT47jUf9Wqufqijor1ljBjP/LsS6OXtqiHJFMOm066RfHjlP+PAWKQ= 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=scuo3Hrv; arc=none smtp.client-ip=209.85.210.179 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="scuo3Hrv" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-8454160043aso1569806b3a.3 for ; Wed, 24 Jun 2026 18:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782350610; x=1782955410; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XWrI8sitTaDcWEaHG+ZnIRCNC7VJeTwjUrHgR3uWgo8=; b=scuo3HrvN19gg3/FDGHEjXterTIX6YzCTf3YrL/mgSmklMg4Pteu1ASWq1ze0TSCI2 tOrTjJdKq+7S7XmstRqQr6yTDXDOSlx9cYtLYHXfxoV2/y1FczGB3ro2FfglXUwhmKab LXLPT30WvAmspm8uTJpCYgjC+tXR/petEfS3eRhUkgJn7H63aH/T3VDvG/zW3HuGcvfj xuS/20SWarkTSodAqtwWa74ZxVLOsyTSQNpk4wc0UtM+qbOJQMmrO7n5ObRwnoEXAF+R zciHVu8KPB6yT5Zrf9r1ZmAfmrCIqqVBwPkytSNt4lsj1d3MRFnQp7sqAZCM0l16tC94 /0rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782350610; x=1782955410; h=content-transfer-encoding:mime-version:references:in-reply-to :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=hRFu5Owsmc8k9BrdSi28KEIP9oppKokjOImhOhoYx0kpaLirZMIYRFRKrkOBUnCwwm ByYY5q3Z18oHZfHx91qKwOsnnhe5XmoPEVb6fwwSMdFFbSUOnNWbtuysgXp/V91DgNtF s3Y1xBcGrFsRSuzKk3B7y6QHvJxnEETooenIOA1HNONM4JROYgTktaTXylZd4uFoX3ln /qYfZ0Ui+6b1OAUV2wEXSE3VO9dLZFnpSIFU+dSUvMzBl0A1QAGY2+HmoO5CJwiMBe0C AwTRxs9IYNWzza1bEquGuBWu3g83rDeXAxs+/ZqPyr8mppHTDn8v/uXtVBzYQnt+eP0R 0dWA== X-Forwarded-Encrypted: i=1; AHgh+RqbqRlxoxvsEf7cfshvkNW9wkWFrujaN1ztgksXDWdbzrNS1QKHSSURkZqIexn1XB4m7lxL4Tq63hwheuM=@vger.kernel.org X-Gm-Message-State: AOJu0YzSQ2YJtdshQ7nCsxGTe+qHYsq/yiDia6z+oiIMRNbIZGZf+u9L Gfor5yHfWNaHOz0ze6yDTT+k21XUxiUsPMoocRyRrqSHK1YTsnoH503a X-Gm-Gg: AfdE7clWAXY2V5EFSFwDomk712I9bNlx2mLqOAdpHRsD1goi9ju+dN7oLuRcw7qAWn6 c1jdV+hf4ItBtI7GxsBdXhMPbOsW5RK64/w8T5T1k7zK/qX1qlycuAAXeJlorX/AYN7LwCMfg2g gtVTV0rwzo8Jmo+qjznCei6kef7YsYDhT9wGKK1DeRfWCnaLxjm6JikR1khN8/96eyogbVEyetw GdBPjK1dAjg8r0g6VX8uDA8dKG+moYdHNsucF2JyfKLAGu9RnQpj86zX5rGx3nf98rS3PV6kIU5 kbf97man1OtMOeXrYXIFYKl0oRxl6UpduTpcezifdjzLCDrstUy0Jq2eSXdmRYiei5M3ZpNAs6b nJdjd2SZ3G60NAnrTP4NlYOb07motxs6kb7AaBxv8GsCeF/6pr3SewHxLPBE72RCGo8S22HKT5M 2mvUDRVAPL4af6IaGOhH5CDc84Jhs= X-Received: by 2002:a05:6a00:2396:b0:842:377a:4dcd with SMTP id d2e1a72fcca58-845b3b1dc40mr642354b3a.43.1782350609949; Wed, 24 Jun 2026 18:23:29 -0700 (PDT) Received: from online.mioffice.cn ([43.224.245.228]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-845a4002bf0sm3272475b3a.25.2026.06.24.18.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 18:23:29 -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] ipv6: fib6: fix NULL deref in fib6_walk_continue() on multi-batch dump Date: Thu, 25 Jun 2026 09:23:23 +0800 Message-Id: <20260625012323.892346-1-zhangfeionline@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260624171156.822055-1-zhangfeionline@gmail.com> References: <20260624171156.822055-1-zhangfeionline@gmail.com> 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