Article View: linux.kernel.netdev
Article #24948[PATCH ipsec 3/4] xfrm: iptfs: free queued packets on SA delete to fix a netns UAF
From: Juan Agustin Niccolini
Date: Tue, 01 Dec 2026 03:21
Date: Tue, 01 Dec 2026 03:21
69 lines
13706 bytes
13706 bytes
IP-TFS sends outgoing packets from a timer: iptfs_output_collect()
queues them on xtfs->queue, and iptfs_timer sends them after the
configured delay. A queued packet keeps its SA alive through its xfrm
route, and IP-TFS frees the queue and stops iptfs_timer only when the
SA is destroyed, which cannot happen while the packets hold it. A
forwarded packet has no socket that would keep the namespace alive. So
when the network namespace is dismantled with a packet queued, the SA
is deleted but survives, and iptfs_timer later sends the packet after
the namespace has been freed, a use-after-free of struct net:
BUG: KASAN: slab-use-after-free in xfrm_output_resume+0xdd2/0x1bf0
Read of size 8 at addr ff1100000d3c3ec0 by task swapper/0/0
Releasing the packet's route then reads the route counter from the same
freed struct net. Namespace exit had already destroyed it, so the
per-CPU access faults in timer context and the machine panics.
An unprivileged user can trigger this from a user and network
namespace, by forwarding a packet into an IP-TFS SA with a long send
delay and leaving the namespace before the timer fires.
Fix this in the delete_state callback added earlier in this series:
free the queued packets and cancel iptfs_timer without waiting for it,
and drop packets that reach iptfs_output_collect() once the SA is no
longer valid, as xfrm_output_one() does. Since namespace exit now
deletes the SAs in pre_exit, the queued packets release their routes
before the xfrm dst_ops are torn down.
Fixes: 0e4fbf013fa5 ("xfrm: iptfs: add user packet (tunnel ingress) handling")
Cc: stable@vger.kernel.org
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
---
Reproducer: https://github.com/AgusNicco/iptfs-uafs/blob/main/iptfs_output_netns_uaf.c
net/xfrm/xfrm_iptfs.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index da5729306a61..320de30ed8bd 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -1930,6 +1930,13 @@ static int iptfs_output_collect(struct net *net, struct sock *sk, struct sk_buff
*/
spin_lock_bh(&x->lock);
+ if (unlikely(x->km.state != XFRM_STATE_VALID)) {
+ spin_unlock_bh(&x->lock);
+ XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID);
+ kfree_skb_list(segs);
+ return -EINVAL;
+ }
+
skb_list_walk_safe(segs, skb, nskb) {
skb_mark_not_on_list(skb);
@@ -2788,6 +2795,10 @@ static void iptfs_delete_state(struct xfrm_state *x)
__skb_queue_head_init(&list);
+ skb_queue_splice_init(&xtfs->queue, &list);
+ xtfs->queue_size = 0;
+ hrtimer_try_to_cancel(&xtfs->iptfs_timer);
+
spin_lock(&xtfs->drop_lock);
WRITE_ONCE(xtfs->dead, true);
if (xtfs->ra_newskb) {
--
2.53.0
Technical Details
Message-ID:
<20261201032200.37030-4-juanagusnicco@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374678-linux-kernel-netdev=dewy.ruReferences:
<20261201032200.37030-1-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374678-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH ipsec 3/4] xfrm: iptfs: free queued packets on SA delete to fix a netns UAF
Date: Mon, 30 Nov 2026 22:21:59 -0500
Organization: Usenet Network
Message-ID: <20261201032200.37030-4-juanagusnicco@gmail.com>
References: <20261201032200.37030-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1602003"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tpDc3m/DQUuB833DpJS3USCGe8Y= sha256:Z4AHehF2S8hfrqC7TPHaAP3ARFleY158YkBl3Z5mKuU=
sha1:dKveMXfE2zYogiHDfv9SyN+xfwI= sha256:DoT4RSccFUZhZ17aVe9i7cvb+C6eflR3RTR23HMHguo=
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 7718F117227; Tue, 1 Dec 2026 06:22:44 +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 ntLY0oPcsHHG;
Tue, 1 Dec 2026 06:22:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374678-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 8E3A2117226; Tue, 1 Dec 2026 06:22:32 +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 2C5802C3A5; Tue, 1 Dec 2026 03:22:23 +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=1796095343;
b=Y6x7rh2qtXLCEZeo9+CyR3mKZ4OpIN5/7dhrOLPpzunH0HP3JfOcgd/6qGeyHCTSCCbC
m/oU9gsKiRecacFEDCqKQBranjY+Jrdd1ItgK72AFCKj1KZksgaZtdv60b7Wvf84/OkQ4
mzWuLLeg1XmCR+4YkMlUjLgzyOXyIKNwuh2g/8zrPex/e/DsS7OQoIR8FD7x/DA73A3/E
OEHOEjuhCqjDJUM2aZkfcSYWP9SExQIJMUEg/cGk84TLf1dfX17R4zpPi3dEwJdjxej+m
J7LnizD9Mp6L68or3mM/XlztGDgX4T9tJblfiN8iBW9Q1XJLivT5GLcawhXAMPWpFMg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796095343;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=7pnP2ln4JQlXuLwaFCbEmunrRfwNdp2ysnAZSg3o/ig=;
b=UKu6etUGHCm2+nAhA4ZfYKM58gZzOa0HNS1ZVC2Zog/VIQ4ehOxLt9ERYX8EkFd209rE
Mp4Pz0aknGa9N2csoBY9vzTWNIkZbZsv24fAboU3ljcTFW00Q4Q10IGTHMXyk1DoxSoOf
vCCSgR9SGen+bDrBY2qshLhuWu0Hri+f4sEJSfonCOeg/XTrtRVHclmC3n8mfXED1490l
NhjiJaXgtNzgDLYtMO3UPAvfTclenw6W569JODZIajGoRphf68rPP/zU41r2nP+vxXylb
hIaMk1gfd91kZn8Z8rOifQa+QmEAvfuc8JXf0ORQNka0p4vhEvja6f5NTU+dlu/4X6Q==
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=KaZQEK7i;
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 0155D606A320;
Tue, 1 Dec 2026 03:22:23 +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=KaZQEK7i
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.181
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796095337;
b=gYd3zHrdfIXrxDiCqDpgahiFDRXS7n9gDeK65jclDq/aXX0UFac+8+hmgTuHZaSwJxGm
I/2F9TdStoScVOvdF+ftmwiK3j887UiXCAtOoCgLVBe+xFDh0FdCPIRgxgWihjLNUwcS0
vY0/lW/nlZTLnyx8RPF4q+82oDC+4uyusVOZ008Goa+nvC+IQ+5c6u+pOf67T6LVQl6+U
yuXXlqpxsRD7UwmHO/eHaQTGd3xIDHboJCrRVKqVz6QZzL1i0CfxHUx21hWATwutA6D/l
NDbqbYx1NpuqjsUXqDAQxDTuVH6TjoJAJzGJjk9XFP9gqIAGVU87wNAH/fCIV85WZqg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796095337;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=7pnP2ln4JQlXuLwaFCbEmunrRfwNdp2ysnAZSg3o/ig=;
b=mHSg/aH0wMi3ODUhw+I1Gt5gvIXGnSzIhF9Godjm0qSxEKySsI2p0WuG8V4ZQQyBX/sh
hpvlqatkHC5KKSQhfkv6Z3rCYaKL3eWUrZMLnDnCuJriFhAmsdhD18B/dzkbSP0pEva+c
xdaKI96p8SxMoWuK7Fa45QIAAnT38zFTXJu30PDSz+6vtJguJMVH5sYR1hxjSW7IGy6QX
raB4h7kHftn7iWXUzInh5PFF6GkptFAQ1fHRoPPxEbsRSEvzGxKAPvpg3Cg81V4W8CrOs
L5bxrXmWAdWF/sMweo+xWt6UdfyClIzihmGXSSZd2bvJ8Ve8W2rKXmANMQdGpe60fWw==
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=KaZQEK7i;
arc=none smtp.remote-ip=209.85.128.181
X-Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181])
(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 C74B8606A330
for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 03:22:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C74B8606A330
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-yw1-f181.google.com with SMTP id 00721157ae682-8b360828905so105298687b3.2
for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 19:22:16 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796095336; x=1796700136; 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:content-type;
bh=7pnP2ln4JQlXuLwaFCbEmunrRfwNdp2ysnAZSg3o/ig=;
b=KaZQEK7iLgLy7aPZJxyGqzAX40/6gZp9ucAe17NIhf7XSuHfobrgFOFwSWBio/NQnI
ft1KhkL5D2LwAotn+xTU73a21iHP60XL+a1SbRaXfTOYo0kyjKuoJeDTgfA+fUCtZmWi
Opj9CZnovSK3y4mJZK8cdiIgV0YFXkGh7X+VsWqJP3JGvl6ryiCxCWGYx6Hr79965xpV
T9dEMif5W2MCzzVEPjACjxW2zjs2TfXhnXMbHS+6ZNExVE64sTQCjUnzs94S7K3TVYCk
topViIw0nfnf0MffORtBCE3jmVZsfNFyyHq/rZ3E+Xvob/BIYHGirSNlhT0AJeOthgau
PaWQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796095336; x=1796700136;
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:content-type;
bh=7pnP2ln4JQlXuLwaFCbEmunrRfwNdp2ysnAZSg3o/ig=;
b=tt0dB+Ksw/zmA8+IzRMrKvMsV99vBLqQWeyKmOlmICIFi/7vLYUbR4z4HhBo0nmHHC
uz47goirvQtcS4sXrdLvlI2BNdFNYzI4GbmW4BehlwhqExDRGxniM8JE5VexVA3kz4wV
19zsLxlJUF+nG2M7aVdl5X8yZaPv7IkQOa5qHn4+LTxn8wpL/Xxh0ukAW6leJOkHdUX9
PsjtNc5quc8LwX6adY1T7JjhFtvwaagrtdEKeMtjh4xpPH2qPWaAGFIhZBpSkQb0QHJa
zRW/+ziMFw5LYlMGP9QrmnhSIHQ0Lj0H0AsaHVF0Il6jfRsGRZhrZpduLhNvF/Dbdb+P
Vi+g==
X-Gm-Message-State: APuU4Z89ahmWC+MRIXkkLeDQpopOX+8/C3fpwYzfGpn3GMbBDwqmrlv2
RCS4K1JWKzrLi42sZk/SlXxpH75eQvLCw2DRLh6y4mB1hhAOVVDBRP32
X-Gm-Gg: AZFdTZcepXCmY5uZ5M0rQHSG/gWdZJzlSb/PNEZc8Ax3t1jy7dilt16axm9CPJVWN7r
Dcq4CntjNrOIqJmDjiWURwiBkeAZwQPDiVwZ4gqDVMFFKOrO+PPZWYlOgRh989cjD9HRmHQNd/7
AL9OziWwHxQZPUdU5J2CPGU7SkMJxOA8TZoByA22Dd0ofsbsjZPPROb5A/dCAnjLz7DKz186Y1t
NoTk2InTwhtnxUmsInagBXbLw37EYM8i38AJeVDXXrtYMbAUqdYNf7vPV83PG9QxQMJO9Kq+/rI
iaBvNtpiBp7SI0q409QA/VVRYeFPYJ3DvwqwmQwWMlgDkQzR0xEkUgibARDhKHyhsBpOH5fAN4X
El3cWKdo0NDHqIya7uorXwBRsv5zNOzDTFlKq5CU29qm8YXtAzrOFhOYTRi4vlHa8pNq8MZSTEb
tCIGiHiBOVTVt8tCzDHqfhe8voZlbEueXbijExAj34SxZhBIufxkuup4yOV02Ifae75/EpHR/id
95ruUwTTDUCNj20s2oyLK7a5b/XFaxZnqKF2toyfTI8dkVXqWfZxpuensbifLosQGTcDwCc0OUP
caOiQSvlqS2rTDGVf5yq8nCdvgQa+AxfFvu9DmBADGYbPhROLGnK
X-Received: by 2002:a05:690c:9a09:b0:8b4:f1a7:4190 with SMTP id 00721157ae682-8b520514f38mr142670737b3.104.1796095335857;
Mon, 30 Nov 2026 19:22:15 -0800 (PST)
X-Received: from VPN-156-19.vpn.usf.edu ([2607:fe50:0:f802::4046])
by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df30e4407sm16484916d50.0.2026.11.30.19.22.13
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Mon, 30 Nov 2026 19:22:14 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
ipsec@lists.linux.dev,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Christian Hopps <chopps@labn.net>,
Antony Antony <antony.antony@secunet.com>,
Sabrina Dubroca <sd@queasysnail.net>,
Shaomin Chen <eeesssooo020@gmail.com>,
Roshan Kumar <roshaen09@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261201032200.37030-1-juanagusnicco@gmail.com>
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