Article View: linux.kernel.netdev
Article #7510Re: [PATCH net] seg6: fix tun_src RCU lifetime on namespace teardown
From: Andrea Mayer
Date: Mon, 26 Oct 2026 14:05
Date: Mon, 26 Oct 2026 14:05
57 lines
11715 bytes
11715 bytes
On Sun, 25 Oct 2026 22:22:22 +0000 Tristan Madani <tristmd@gmail.com> wrote: > Found by manual code inspection while auditing RCU lifetime > patterns in the seg6 subsystem. The issue is theoretical -- > found by reading the source, not triggered in production. Hi Tristan, thanks for the info. The pre_exit in this patch introduces a NULL deref. It sets tun_src to NULL before the netns devices are removed, while set_tun_src() can still read it. I ran a stress test on net with KASAN. A userspace program sends UDP packets in a loop from init_net through a veth into a test netns, where a seg6 encap route without a per-route tunsrc forwards them. Meanwhile, the test netns is created and deleted repeatedly. With this patch applied, KASAN reported a null-ptr-deref in set_tun_src() and the kernel panicked: BUG: KASAN: null-ptr-deref in set_tun_src+0xd1/0x240 Read of size 8 at addr 0000000000000000 by task udp_flood_user/379 Call Trace: <IRQ> set_tun_src+0xd1/0x240 __seg6_do_srh_encap+0x410/0x710 seg6_do_srh+0x65e/0x6a0 seg6_input_core+0x87/0x4c0 lwtunnel_input+0x18d/0x420 ipv6_rcv+0x44f/0x460 __netif_receive_skb_one_core+0xd6/0x130 process_backlog+0x2cc/0xa00 __napi_poll.constprop.0+0x56/0x270 net_rx_action+0x327/0x730 handle_softirqs+0x15a/0x6c0 do_softirq+0xb4/0xf0 </IRQ> <TASK> __local_bh_enable_ip+0xdd/0x100 __dev_queue_xmit+0x538/0x1030 ip6_finish_output+0x280/0x640 ip6_output+0x118/0x380 ip6_send_skb+0x99/0x210 udp_v6_send_skb+0x397/0x760 udpv6_sendmsg+0x1100/0x14d0 __sys_sendto+0x219/0x2d0 ... Kernel panic - not syncing: Fatal exception in interrupt Without this patch, I ran the same test with 1000 netns deletions and KASAN reported nothing. Ciao, Andrea
Technical Details
Message-ID:
<20261026150541.a5a34642db9d1523f839f644@uniroma2.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351932-linux-kernel-netdev=dewy.ruReferences:
<179278529389.3327.1530536500905686255@kernel.org> <20261025222222.1064464-1-tristan@talencesecurity.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351932-linux-kernel-netdev=dewy.ru
From: andrea.mayer@uniroma2.it (Andrea Mayer)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] seg6: fix tun_src RCU lifetime on namespace
teardown
Date: Mon, 26 Oct 2026 15:05:41 +0100
Organization: Usenet Network
Message-ID: <20261026150541.a5a34642db9d1523f839f644@uniroma2.it>
References: <179278529389.3327.1530536500905686255@kernel.org>
<20261025222222.1064464-1-tristan@talencesecurity.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="1322066"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VfkI7h0QHrqsXcFotpANNznuSlY= sha256:rpZbFTJ/RoTxm0TkkWz3lU7chTA6zU+bPp1Mcbx8Vag=
sha1:Cqd/FAid8eiYyUSmrU1fCai+Z+g= sha256:dh+2sczIlKRaLxtti5eLI3MibQ4+daViD1XKThsvtE8=
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 14655125BAB; Mon, 26 Oct 2026 17:07:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -4.761
X-Spam-Status: No, score=-4.761 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, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, NICE_REPLY_A=-1.712, RCVD_IN_DNSWL_MED=-2.3,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=neutral
reason="invalid (unsupported algorithm ed25519-sha256)"
header.d=uniroma2.it header.b=UGmjf8VY; dkim=pass (2048-bit key)
header.d=uniroma2.it header.b=tp/eiOPR
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 bI5NJz6X2mmc;
Mon, 26 Oct 2026 17:07:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-351932-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniroma2.it
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 12540125BA8; Mon, 26 Oct 2026 17:07:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 7269329201; Mon, 26 Oct 2026 14:06:28 +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=1793023586;
b=jFWfrOYCMgmV6PZ5V+15Mys8TbROlmpuGbX+fzJUWqUodMFS9tpcBARz1KRVoI1DM5zj
ZeOyGR01YJfrOUE/W/Hbc/aLyhWWcfhdnikndlRcNIaXmgWMHbfZSAv2dqbhKWEW1TaCQ
Nv1dQ25pCkP1WzTqKnK9UjqYAaOEr9hsaiB0xyK0pE6a38NNoO9iLNyn4qhbvBS2pdOEu
Q1iOyl2OBjBP1gujUtNLWLpDJGZzFJVxVQkSWvXuFMt1HsXAg3uteA2DJdlNpx4EB6fEp
vZsqK7RHOPsTh0IuKN9Zxv/Bbeiv04daiQTyQFwI0oC3PQC9bbavuLchGndJYkfQstw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793023586;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:Date:From:To:Cc:Subject:Message-Id:In-Reply-To:
References:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:Mime-Version:
Content-Type:Content-Transfer-Encoding:X-Virus-Scanned:
X-Virus-Status;
bh=S+aChkfaMd9EivevKx38Q/7Syxky3lnzhcs/iXmA7Hk=;
b=Sr9SwgLZlAeJIxqfPKDntS239azkV6z0CfbbhUNdq58t/EOHFVEnanHeB2A3yV91siVb
vNJAKaO9b0pfl1CdOrsk/TS+peCz4ShOgLde7qvfZhv8GnB0PM24UOuyxVclySdBr1+mX
ok5AHX9XC4UVecOb3JfyDjnUO1WIRAf+6dxfvfUFBzBH3xq1UtE24oUDlET930VU+lH7J
5O+vjdFtYKUCJFirsOuA+ZXsptmSKHvq4XU/dzuUY+Wgg4G5BJPulWl1S19iAyDN6GQz/
4Hvk6Sf8D3MbU2vgnwfXwxvxAbwDbRm6MqJtbfqX+Ss5lAL38SDw6MZI4FhyzzJtysQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=UGmjf8VY;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b="tp/eiOPR";
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
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 1FCA8606A321;
Mon, 26 Oct 2026 14:06:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=UGmjf8VY;
dkim=pass (2048-bit key, unprotected) header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b=tp/eiOPR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=160.80.4.37
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793023574;
b=Se8ojdLfN8bCE91m7KM1EmiFM81hQbWRMOl7UbdodNjzQBu18h6Pj+NuJWk5YjMhwUBu
CbUEFDegeOYu1QMO5hOcBvd7gjqKzenAoLCtJ88QTOkM4BOOWaOG2XTgfjyl3XWL5++Wq
W4rYBybUl7TfeLboEIRJXwOKtB88Co5Sy675qMv8Ot+umh9sfW1RvqF9jukjv38tt6VF5
13lQI9eeqXAAavO+fOD8S0hRPFXlgN7H11LeZd33mJgvGLd/+YrC//2MeW+4QZJSGvpNw
SOH3d0YtE2ycACxyef/YLDv/kILxyJfDijFWIhsx5sHLVlY8cNgBUuZMHicsGNRnyvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793023574;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:Date:
From:To:Cc:Subject:Message-Id:In-Reply-To:References:X-Mailer:
Mime-Version:Content-Type:Content-Transfer-Encoding:X-Virus-Scanned:
X-Virus-Status;
bh=S+aChkfaMd9EivevKx38Q/7Syxky3lnzhcs/iXmA7Hk=;
b=QwxLNJMtkXkRoboqGtILc6LEoQmnfbKCOmEZCLymAoqBi6RbaMLhnnHP7Fmci9WyxIec
lz+dy8AaaLVSzqnhfhKlKVHlFDGPnyVZqBdDAZQhilxGzkVsB1FX1NhpSAyf2NCp2gPLf
/zv6SPMZ3jzXEsbzB+vVfh9SiODOgzTy64Cq6g5bdgRrMrJqr3CqeOkEBVIL5sShJb7rn
XJz5UiFU9un1UMq0fDoBm2ytCUnGjXL2th6l9aFZkNr43jrxAwJ/96ct5aNg305hVxZSC
BSBC6JoettlRvRZyuDHebjPj9bHGgrX8Qxg22ih2kGwF/c9/D3W4EEdBkRvwIeJNivQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=uniroma2.it;
spf=pass smtp.mailfrom=uniroma2.it;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=ed25519-sha256 header.s=ed201904 header.b=UGmjf8VY;
dkim=pass header.d=uniroma2.it header.i=@uniroma2.it header.a=rsa-sha256 header.s=rsa201904 header.b="tp/eiOPR";
arc=none smtp.remote-ip=160.80.4.37
X-Received: from smtp.uniroma2.it (smtp.uniroma2.it [160.80.4.37])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 53C65606A31A;
Mon, 26 Oct 2026 14:06:12 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53C65606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniroma2.it
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniroma2.it
X-Received: from smtpauth-2019-1.uniroma2.it (smtpauth.uniroma2.it [160.80.5.46])
by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 69QE5aHh010301;
Mon, 26 Oct 2026 15:05:42 +0100
X-Received: from lubuntu-18.04 (unknown [160.80.103.126])
by smtpauth-2019-1.uniroma2.it (Postfix) with ESMTPSA id 8AE4F1203BC;
Mon, 26 Oct 2026 15:05:42 +0100 (CET)
X-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=uniroma2.it;
s=ed201904; t=1793023543; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=S+aChkfaMd9EivevKx38Q/7Syxky3lnzhcs/iXmA7Hk=;
b=UGmjf8VYEjQ3iKMxhBykCXQ2zVJ0aAgYaycPpfcNB4aRZ9SJPM99SxoBW9h5/j5FNCI1jX
G3aKXx7/2EAJL+Aw==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniroma2.it; s=rsa201904;
t=1793023543; h=from:from:sender:reply-to:subject:subject:date:date:
message-id:message-id:to:to:cc:cc:mime-version:mime-version:
content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=S+aChkfaMd9EivevKx38Q/7Syxky3lnzhcs/iXmA7Hk=;
b=tp/eiOPRb951NNKopf1HgWI0lb4Zs6BspwO+XzwB2jaDUstzbN2eXW0i7u0eX7/a3ivBQD
vcBj+CKvtZIg64wYdSRZ9f3RhdeKCe0iaDwQHsbm2yDP1hC8KZx7ZY0cF7QSs6RxviAOeX
Pie/ZdmIhSLLP9rfV+OU7dQo9SU3zbnlzx/FL7JSbEp2JB5SvX48W/tDe1zC72kg3Y21mP
mU124AcC124ed4z3oko1LbXMgpf4/Zz7ADttTv0eM1UU6W6LE2EEa4PbCeyaERdr02643j
dEsI56USpDzXKTGCYs8lo11ptlsipiiBM1HdUzhQKGKLeiaDZmymhH1wXt+YGA==
X-Cc: netdev-bot+sinfo@kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
tristan@talencesecurity.com, david.lebrun@uclouvain.be,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
stable@vger.kernel.org, stefano.salsano@uniroma2.it,
Andrea Mayer
<andrea.mayer@uniroma2.it>
X-In-Reply-To: <20261025222222.1064464-1-tristan@talencesecurity.com>
X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
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
X-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015
X-Virus-Status: Clean