Article View: linux.kernel.netdev
Article #20766[PATCH net] ipv6: route: fix use-after-free in ip6_confirm_neigh()
From: Zhou Qiuyue
Date: Mon, 23 Nov 2026 05:30
Date: Mon, 23 Nov 2026 05:30
138 lines
15215 bytes
15215 bytes
ip6_confirm_neigh() loads dst->dev with dst_dev() and dereferences the
resulting net_device without holding RCU. The load is only a READ_ONCE();
it does not pin the device. rawv6_sendmsg() and udpv6_sendmsg() reach
dst_confirm_neigh() when sendmsg() is issued with MSG_CONFIRM and
MSG_PROBE, without holding RCU or a net_device reference.
Route teardown drops the reference the dst held on the device:
dst_dev_put() does it for dsts removed from the fib tree, and the
uncached-route flush does it through netdev_ref_replace(). Both replace
dst->dev with blackhole_netdev, so a reader that loaded the old pointer
just before the replacement can dereference a freed net_device while
testing dev->flags.
Take rcu_read_lock(), load the device with dst_dev_rcu(), and keep the
section through the flags test and __ipv6_confirm_neigh().
KASAN reports (trimmed to the relevant frames):
BUG: KASAN: slab-use-after-free in ip6_confirm_neigh+0x802/0x8c0
Read of size 4 at addr ffff888104f960b0 by task confirm_race/121
Call Trace:
<TASK>
dump_stack_lvl+0x55/0x70
print_report+0xcb/0x5d0
kasan_report+0xb8/0xf0
ip6_confirm_neigh+0x802/0x8c0
rawv6_sendmsg+0x116b/0x3780
____sys_sendmsg+0x7af/0x9b0
___sys_sendmsg+0x145/0x220
__sys_sendmsg+0xf8/0x190
do_syscall_64+0xee/0x500
entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Allocated by task 117:
__kasan_kmalloc+0xaa/0xb0
__kvmalloc_node_noprof+0x216/0x5d0
alloc_netdev_mqs+0x7e/0x11c0
rtnl_create_link+0xaa6/0xe30
rtnl_newlink+0xd22/0x1de0
rtnetlink_rcv_msg+0x697/0xa00
Freed by task 117:
__kasan_slab_free+0x61/0x80
kfree+0x201/0x440
device_release+0xc8/0x240
kobject_put+0x101/0x1e0
netdev_run_todo+0x611/0xe70
rtnl_dellink+0x343/0xa50
rtnetlink_rcv_msg+0x697/0xa00
The buggy address is located 176 bytes inside of
freed 4096-byte region [ffff888104f96000, ffff888104f97000)
The faulting address is object offset 176, the 4-byte dev->flags load.
The lifetime bug comes from the v4.13 series that removed the dst gc
list. Commit 9514528d92d4 ("ipv6: call dst_dev_put() properly") made
route teardown release the net_device reference held by the dst, so
dst->dev no longer pins the device for the lifetime of the dst.
Later commits changed the replacement target to blackhole_netdev and
added dev_rcu, but did not add RCU protection to this reader.
The lifetime change is present from v4.13 onward. Kernels that reach
this callback are affected, including current mainline, net-next, and
the 5.4.y, 5.10.y, 5.15.y, 6.1.y, 6.6.y and 6.12.y stable branches.
dst_dev_rcu() is available in current 5.15.y and newer; 5.10.y and
older need the equivalent rcu_dereference(dst->dev) backport.
Fixes: 9514528d92d4 ("ipv6: call dst_dev_put() properly")
Cc: stable@vger.kernel.org
Signed-off-by: Zhou Qiuyue <n0ps1edzz@gmail.com>
---
Window amplification for the KASAN run only:
struct net_device *dev = dst_dev(dst);
+if (in_task())
+ msleep(500);
daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr);
The sleep runs in process context (rawv6_sendmsg), so RTM_DELLINK can
reach netdev_run_todo() and device_release() before dev->flags is read.
It is a verification aid, not part of the fix.
Report context: 7.4.0-rc2 #25, CONFIG_KASAN=y, PREEMPT(full),
kasan.fault=panic. Full log: evidence/dyn-confirm/qemu-kasan-confirm.log.
Object detail from the report:
The buggy address belongs to the object at ffff888104f96000
which belongs to the cache kmalloc-4k of size 4096
Base tree: netdev/net.git main at af6737b90668. The pre-image blob in
this patch matches that tip exactly. The same hunk also applies to
netdev/net-next.git main at eb6d6c80d354; the target function is
unchanged there.
net/ipv6/route.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1b2dcc0..6bdd442 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -257,16 +257,21 @@ static struct neighbour *ip6_dst_neigh_lookup(const struct dst_entry *dst,
static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr)
{
const struct rt6_info *rt = dst_rt6_info(dst);
- struct net_device *dev = dst_dev(dst);
+ struct net_device *dev;
+
+ rcu_read_lock();
+ dev = dst_dev_rcu(dst);
daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr);
if (!daddr)
- return;
+ goto out;
if (dev->flags & (IFF_NOARP | IFF_LOOPBACK))
- return;
+ goto out;
if (ipv6_addr_is_multicast((const struct in6_addr *)daddr))
- return;
+ goto out;
__ipv6_confirm_neigh(dev, daddr);
+out:
+ rcu_read_unlock();
}
static struct dst_ops ip6_dst_ops_template = {
base-commit: af6737b9066832a2017c281159950ba92385ce00
--
2.34.1
Technical Details
Message-ID:
<20261123133000.1.n0ps1edzz@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369087-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369087-linux-kernel-netdev=dewy.ru
From: n0ps1edzz@gmail.com (Zhou Qiuyue)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] ipv6: route: fix use-after-free in ip6_confirm_neigh()
Date: Mon, 23 Nov 2026 13:30:00 +0800
Organization: Usenet Network
Message-ID: <20261123133000.1.n0ps1edzz@gmail.com>
Injection-Info: usenet.network;
logging-data="3812430"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:h+Fhz6YNwOCnmKC+Y4Z4j63iGaQ= sha256:R453Fz913dtONbYIQcdw6WSstIOYL7BPSNuUe4n6N3A=
sha1:gnrgual7YMwu3brxZRkO/0FnnbY= sha256:bkd9eOI0Co6+aAXJAfCLfaxDoVmlYPT0z8HkTwcAO4U=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 490C9125D90; Mon, 23 Nov 2026 09:59:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id C3wJKskttDzj;
Mon, 23 Nov 2026 09:59:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369087-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 1360A125D8E; Mon, 23 Nov 2026 09:59:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id E0D1C2D402; Mon, 23 Nov 2026 06:59:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795417175;
b=19BYdnBQpL7YZ9klopkZDtld9fo1spG0+hSBdxIbJQGFsvPPL1c1yJaCJyHukXm6LDAB
2IGh7aGUy15BOTOTeRCFcNp2QpBTNKb7gVovGWciBMwHlngHKqNsBdBAA8H0gt4LTfWOI
8mAbpOZoTKqkRLor8dWi0HDoIVrBsMzgKiSLA87rW9SDHlpmih0hP2S2VlhFCkyVRB+kT
G0K7v7J8A25FGoh+3UYSH5tlCmmvP8AP87688tmrUW0hl4WHbWqZXR7rmTuaPn2OBtu6p
nA4DolraTzwtdz7mlh4Cg9MbcHBccRtG4fLxSirOoFmDzmS4hWaDBYuFihP41U9ec4Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795417175;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Message-Id:From:Date:Subject:To:Cc:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence;
bh=ITNEBQ5K9jrLwJ0lzsPTcMQ84D5JQ6hqp/46Yjer+kM=;
b=AyYthc0flIxYdtFHpZc/ZA1AVCFtO3CxJJyDN9WXB+cV2NjPiSaBZpqprmlZDrfQCrmt
iNB2HKESK4rCUGSRlkQIWmSVbfKoHoNBjy0W857tgsx0KPdAwj9jpEnoBaa+zEnw9Ud2V
9vEWohVZm6nwJ+fjvN6Su184cBlEia7DgmlShOVW0Tj0tVwZejxqI/4LTOL7GqRIGc0O8
HY0b72YhanxX/tTEQGpopLjV0zL2ZB5smUH1AmJFFC0vssk+zqs5dt3pjeK9WND3h2nWM
OSLJ8Jw0esgGhJyswwiAUZbennyyDQf8VzcXJ/d9+TSLJOdc34JwaUEwPjPB+gaGnbw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i+f21Eqw;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 59868606A333;
Mon, 23 Nov 2026 06:59:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i+f21Eqw
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.227.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795417174;
b=Mi938Rf7GdJQTOOIfBgc0TeQG37JBoZxrbKv3VFuXNiQlCtNHvxqHO2m7hH/ncEVcosc
1cpMoqJhIzBcbkktqlk7tRtKqlkBJCsFtqhAlHc3i2nsDkUbyeEk+88fzIKWnJLe9NVPO
puDquupqG9SdRZyyUqW/pwnS8wX6hbLlEyXVOv3C3B9Ni17PRDWyx+UdhxigoAxm6l8fp
eGK5s81C+fLtE59garVOWWaGfk5wlkbMzH0f/pccsrKy4LLvvBq7r1u0W9EL6UadrVVb5
G66sbqpDBY5qStIXwI9fGHp/EmRpXbYvMUl4uchi0ggxpdB8rrWQA9LVCkicVuHi4WQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795417174;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:From:Date:
Subject:To:Cc;
bh=ITNEBQ5K9jrLwJ0lzsPTcMQ84D5JQ6hqp/46Yjer+kM=;
b=p9MYe3IxRGyZELuS/QaNaIQdL/xTUvmO+gvN6uRYGHOXxDrGf2cIck+9mgjwWNlwiXDc
6CQ3aCwn/Y8nfly9+T/8yIgFOz2Ja3C2yEkVT0GVKU80kcHTJzovpfwZMQUoayQuMq8fh
J0+Ry1/RHC0kRpXsWMHzLLhb/peJUp+siyVRKYbvroVDSDycjebPrlyVaht2LgOVfBU3W
+YF4hgnuI7i9Dhc7pCZrAi6yW+9PSouKh0bXUkqUXnzb4DYxA7ByccE0D9/mfCHkZMANk
pfG9SKbbWJjREu97NyiF1Z4tXqApdhTOih6/zEDSv9tsAkD+TbV9qSFtDZnIj0EWOxg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=i+f21Eqw;
arc=none smtp.remote-ip=74.125.227.139
X-Received: from mail-pj2-f11.google.com (mail-pj2-f11.google.com [74.125.227.139])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19BA8606A31E
for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 06:59:33 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19BA8606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj2-f11.google.com with SMTP id 98e67ed59e1d1-3b468d0dbf2so236641a91.0
for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 22:59:33 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795417173; x=1796021973; darn=vger.kernel.org;
h=cc:to:subject:date:from:message-id:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=ITNEBQ5K9jrLwJ0lzsPTcMQ84D5JQ6hqp/46Yjer+kM=;
b=i+f21EqwB8uSp6aBu/6vaZvpSnavvNOonlPB7hOqmvJCGdzNTo1VMJ5zLCE2Gq9d0/
oHy3ycLfs1+0m9RKQyQaf5aUlbafF4wWqchVGTcL5GXYTeGzCYRbF/ho685lS2fkdV5F
LBkS3mzOUKygReddlZZPhK3S3/B5VS2ndrq4J5FCYft3/6JCOwuqBNZDc40OfPX/dkp8
boOTltPQ43m4TIsSwqNCXf+YQqZWkpoB9z4u0tPJLyiTGVkgtd8/WeM00pOB1Kib8FMr
F9UEtm8iO/+EtgaRxxpU9thRxUm9c8xrksApKCFEXtK8unsAIK2kxiQ3+EK7xKO0AwBZ
egNA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795417173; x=1796021973;
h=cc:to:subject:date:from:message-id:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=ITNEBQ5K9jrLwJ0lzsPTcMQ84D5JQ6hqp/46Yjer+kM=;
b=FEkCVOYhygavEa6Ngosh4rqiXGuN52oSP2SfdUUqfTskdHVYhs70ePSxtUwaK+Uz/F
FVzHJnYFBKQUW7BRagRAnWZA4a4GAJ5g7h+Gcv3YZKQme/LCnPuJ/a7W7DAZ3YX1XA6h
A2C17l7pL/2S9OKYQPRa4Aq13AlU+OHayxlaESLFacTsQ6zwM7jru7ZcLo9wQvGstvOG
wkvZ2dhuyXJOg5IO96nBPw18Ve9msqZFrkaGmvABDDvi6U3RF8QlKmaBTjhOk8hcmAde
8sxTSy81R8UlLJYZm8CSWnKTF9y1dYARl0NJeldKEghNUOjhm2pHmFR3Laku6eZJVejW
AHqQ==
X-Gm-Message-State: APuU4Z/xyO2yn8kP6cApGwoX9j2I3EgR8sQtFcbDfQWyWt/0CeuKrLtX
Lie9MRo5udHLldfBvxlHzBZcGFM5ZvTKsAmhqMt8s/KcmL8PlMH76aA8XAvfyJjZ53ZHeQ==
X-Gm-Gg: AZFdTZdo0CoVt9uX9qwRTuGI8FXl+7eYGDLHXtEyFlGJN3EHVPX8/LbT2l8N+KlMjwX
QPXRQJuzE/fJ0tTZ+7zG3U2jOEI8dZ1nZBJPjUPXj4Pc2vqtlKxtHIEUhoq1c73AXxLLUVaeZGl
gWK+0KgaaJyuNAXwIE6TY1VJYGylaXkWG2e0bnZouewZ9cr2ekHdwUbODpctnaacrA4zy3KbWoX
lCepqx50g2xa3UA+haNqgs8wX6fDZHrs56YJuiDnd04l5D5IAKHH/RD3WpYpRK1m1C/GyUv84Jp
fJJzhiaC3sIsy1X2aleouHALJ5pZBncTTeNu9/xbglrK8ThwcokGlXUKtHpbqB5WzaX5FkU+Ybt
c2BC2aAtZAkMbyQHzoNJsvrIGu1p4ZybjYSJ1rqqfFjO9MeXMM+ou5lqe4Bc+dHpYzE7J/3TFte
EN0WH9PikwAf5M7t6E3J0SHERi9NnR8kNZkYtnlruGQ29qg0Ym6czYR1Pjw3smg2lBW9Zo07JD6
KT01dT/p5iIXumIYt0lVs6UVzSoRLOM2HBievKE5bTh3OSL2YAj7J8wZ2oLTpZR89RmrDGzynl7
tG0RUMUwiFUJfF/ajXSY7AEpv4mxX1iGyhPlrUkMMnUOLs2e7RLm7K4e
X-Received: by 2002:a17:90b:390b:b0:3b4:1336:4f6c with SMTP id 98e67ed59e1d1-3b41c7b6994mr9227969a91.2.1795417173293;
Sun, 22 Nov 2026 22:59:33 -0800 (PST)
X-Received: from smtp.n0ps1edzz.local ([120.253.139.222])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b41ad0b2c4sm16248962a91.4.2026.11.22.22.59.30
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 22 Nov 2026 22:59:32 -0800 (PST)
X-Cc: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
David S. Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Hangbin Liu <hangbin.liu@linux.dev>,
linux-kernel@vger.kernel.org,
stable@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list