🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24946

[PATCH ipsec 2/4] xfrm: iptfs: look up the device of held packets again to fix a UAF

#24946
From: Juan Agustin Niccolini
Date: Tue, 01 Dec 2026 03:21
121 lines
15606 bytes
A packet held in the IP-TFS reorder window, or as the in-progress
reassembly packet, keeps skb->dev without a reference on the device.
If the device is deleted in the meantime, xfrm_input() reads the freed
net_device when the packet is released, a use-after-free:

  BUG: KASAN: slab-use-after-free in xfrm_input+0xbb/0x2620
  Read of size 8 at addr ff1100000efec100 by task swapper/0/0

The freed device's core_stats pointer is then used for a per-CPU
increment. Once the memory is reused for data the user controls, that
is an addition of a chosen value at a chosen kernel address, which is
enough to escalate privileges to root.

An unprivileged user can trigger this from a user and network
namespace, by sending through an IP-TFS SA with a sequence number
skipped and deleting the receiving device before the drop timer fires.

Fix this as ip_expire() does for IPv4 reassembly: record the ifindex
when a packet is saved in the reorder window, clear skb->dev, and look
the device up again when the packet is released, dropping it if the
device is gone. Since the previous patch, a held packet never outlives
its namespace, so the lookup runs on a live one. A completed inner
packet takes the device of the outer packet that completed it, as in
ip_frag_reasm().

I found this bug during an LLM-based audit. A syzbot report
and a previous proposed patch for this bug exist (see below).

Fixes: 6be02e3e4f37 ("xfrm: iptfs: handle reordering of received packets")
Fixes: 075694765446 ("xfrm: iptfs: handle received fragmented inner packets")
Cc: stable@vger.kernel.org
Reported-by: Roshan Kumar <roshaen09@gmail.com>
Link: https://lore.kernel.org/netdev/20260921083602.814584-1-roshaen09@gmail.com/
Reported-by: syzbot+0008ea314a1096dee2b6@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0008ea314a1096dee2b6
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
---
Reproducer: https://github.com/AgusNicco/iptfs-uafs/blob/main/iptfs_reorder_uaf.c

I have an exploit that uses this bug to escalate privileges to root from
an unprivileged user. It is available to the maintainers on request.

 net/xfrm/xfrm_iptfs.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 0dde380eb16c..da5729306a61 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -939,6 +939,7 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq,
 	} else {
 		/* We are done with packet reassembly! */
 		iptfs_reassem_done(xtfs);
+		newskb->dev = skb->dev;
 		iptfs_complete_inner_skb(xtfs->x, newskb);
 		list_add_tail(&newskb->list, list);
 	}
@@ -1248,6 +1249,15 @@ static void iptfs_input_ordered(struct xfrm_state *x, struct sk_buff *skb)
 	xtfs = x->mode_data;
 	net = xs_net(x);
 
+	if (!skb->dev) {
+		skb->dev = dev_get_by_index_rcu(net, skb->skb_iif);
+		if (!skb->dev) {
+			XFRM_INC_STATS(net, LINUX_MIB_XFRMINERROR);
+			kfree_skb(skb);
+			return;
+		}
+	}
+
 	seq = __esp_seq(skb);
 
 	/* Large enough to hold both types of header */
@@ -1446,6 +1456,13 @@ static void iptfs_set_window_drop_times(struct xfrm_iptfs_data *xtfs, int index)
 			      IPTFS_HRTIMER_MODE);
 }
 
+static void __reorder_save(struct skb_wseq *s, struct sk_buff *skb)
+{
+	skb->skb_iif = skb->dev->ifindex;
+	skb->dev = NULL;
+	s->skb = skb;
+}
+
 static void __reorder_future_fits(struct xfrm_iptfs_data *xtfs,
 				  struct sk_buff *inskb,
 				  struct list_head *freelist)
@@ -1491,7 +1508,7 @@ static void __reorder_future_fits(struct xfrm_iptfs_data *xtfs,
 		return;
 	}
 
-	xtfs->w_saved[index].skb = inskb;
+	__reorder_save(&xtfs->w_saved[index], inskb);
 	xtfs->w_savedlen = max(savedlen, index + 1);
 	iptfs_set_window_drop_times(xtfs, index);
 }
@@ -1626,7 +1643,7 @@ static void __reorder_future_shifts(struct xfrm_iptfs_data *xtfs,
 
 	/* We've shifted. plug the packet in at the end. */
 	xtfs->w_savedlen = nslots - 1;
-	xtfs->w_saved[xtfs->w_savedlen - 1].skb = inskb;
+	__reorder_save(&xtfs->w_saved[xtfs->w_savedlen - 1], inskb);
 	iptfs_set_window_drop_times(xtfs, xtfs->w_savedlen - 1);
 
 	/* if we don't have a slot0 then we must wait for it */
@@ -1720,10 +1737,12 @@ static enum hrtimer_restart iptfs_drop_timer(struct hrtimer *me)
 		kfree_skb_reason(skb, SKB_DROP_REASON_FRAG_REASM_TIMEOUT);
 
 	if (count) {
+		rcu_read_lock();
 		list_for_each_entry_safe(skb, next, &list, list) {
 			skb_list_del_init(skb);
 			iptfs_input_ordered(x, skb);
 		}
+		rcu_read_unlock();
 	}
 
 	return HRTIMER_NORESTART;
-- 
2.53.0
Technical Details
Message-ID: <20261201032200.37030-3-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-374677-linux-kernel-netdev=dewy.ru
References: <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-374677-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH ipsec 2/4] xfrm: iptfs: look up the device of held packets again to fix a UAF
Date: Mon, 30 Nov 2026 22:21:58 -0500
Organization: Usenet Network
Message-ID: <20261201032200.37030-3-juanagusnicco@gmail.com>
References: <20261201032200.37030-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1601890"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jHB6jBpiP65wEc2hV9YjTgHGshA= sha256:ru6Qge4uqFx5umJkL8ciWjrzTD3Pj7gLMzzlpW/XX9U=
	sha1:OS6Jc5LseV+vdvQ7mbI+D2XHcGs= sha256:Nxg7NPLs/sA9GJbUOv3Y2iIZ9eZakk1XtRTI/VnpbNk=
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 A5D60117227; Tue,  1 Dec 2026 06:22:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, URIBL_BLOCKED=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 Mn714NzWV-94;
	Tue,  1 Dec 2026 06:22:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374677-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 1019E117224; Tue,  1 Dec 2026 06:22:20 +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 2D2FD2CD39; Tue,  1 Dec 2026 03:22:15 +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=1796095335;
	b=Ofda1JWBto3GKI5dnuLPXMCMfQA1FFCPGAVU4lXN5oC7pb3nLhOx0/Nr9FCAc03lkOwf
	 rkFIVExRpT4gYyHy0YUQ+SX0tkBmr3kflfFBRcPLPllXRevH1/HXkZQY7MfH0U6vTITkh
	 Hadc06QLMwxJDbMpD5jgVqHbifenrwkf4EwJQcPsy2YrLVm2FWpI6SfPkw83zSLw2gONQ
	 Z94i8QgW0CWzqTEdjIkxYxuxxRzkGEIPtZMTTwUPnr6jNZZ+enVwZQuDay5fNsTQc51mf
	 BbjfO+o8oAZaoCkOyci5poGyWnoBK9easf1XD41rWFVXuOJN+ubjuirbUxSjVIfT58A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796095335;
	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=8QMxQ2EaiARSv9t79RMwUb0uHPjseoQ3LpegArnAN3M=;
	b=41kGYP6Pvtk+r9TAKfoi5RFDWC7HyuDg2iJ6bxBaEJOql2hTxCua6WUO9oF8/ah6Hpvm
	 XiQ1goy88Xw5En01vmzdNs/SEI1XOytBtVypxRjq9ZwXHqJaQzUT+BE8GF8NRIl2B6pcJ
	 w6NXD0WcN14/ECMqRazpx9TgQhq3oQu6cE5iF2EZTDkG0yXyVQNXSjzHUA7CvwT5TV9lK
	 jxhNxQc+eKH9IqzvupwfSGfEr/SiQ0ArPrg11hw4yfYiDSZLATaRM5gS7glj0V8jxB7m6
	 54M8+xnlKahXx4pnfYJMTTsQdC14MMyxZjdRtJpi8tSHPBrNApskcgd4YfiTozLL/dQ==
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=SG7bPAJl;
	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 F4045606A31A;
	Tue,  1 Dec 2026 03:22:14 +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=SG7bPAJl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796095334;
	b=FhkVoWT8hunWyQl9Cakj3XjNl0TkvwghXJfe+gwielMs167DnuahkB9wbKNTuWW+IstI
	 +bMkUSmN1xvjI8lDoWd+kuGW9fXjtFHJGmf+rpsuiKoflGy+SwhxkiNFfGO+vRo+Xw6vm
	 Eve/AYcu4Z1gO0PU3TaRtln2xPw0Jal5wqsEirg69suxW5Ur3j3FjJaet1HGvHIp39YTO
	 MAsy2WuJugg+55z3AvSbRC/2xPXt0n1fEA7mzL+ncOj4QNyMoo1mMkECiiHhRovblexgP
	 1r8Z++bavPNWNFTRbx7taqmNKgNRiz52lsAFsZle9LwrzdNAdZZ2PcoBNR0A7l95PtA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796095334;
	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=8QMxQ2EaiARSv9t79RMwUb0uHPjseoQ3LpegArnAN3M=;
	b=hwsWFa32l55Vbqsg33iqK5DtHeOO+Cw4mAe/pWkDfqRIkxFWaC6Hqw+nf5mqdG3XI6t/
	 A6FzSiHhf5P30gCBLgmB6zysf7wMjxQcuMzTas6TYyTRNBEKt0MLikDCQvmvSNGExWHoi
	 wcjOFKy0k6LejED0Q3W66tfUjHb6Y98dUfBTh8d9BGa2L/5XoJlsgl0mt4lDIe1/DHXt0
	 wfM+p6jMgFwq4WPM8h3ZO/HeHW6MdkiLY8NfuEZseDAtF48hIZO7znpbHKV3ojsBz4Q1v
	 n/cRq8rvTZzx4ImILgSxair9pIGpzw0HcNev73gK6ws6wJimAeLjJPXin3ZdQp0u1pQ==
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=SG7bPAJl;
	arc=none smtp.remote-ip=74.125.224.44
X-Received: from mail-yx1-f44.google.com (mail-yx1-f44.google.com [74.125.224.44])
	(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 CDA60606A32D
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 03:22:13 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDA60606A32D
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-yx1-f44.google.com with SMTP id 956f58d0204a3-67da3d03263so11434196d50.1
        for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 19:22:13 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796095333; x=1796700133; 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=8QMxQ2EaiARSv9t79RMwUb0uHPjseoQ3LpegArnAN3M=;
        b=SG7bPAJl8bEZfdYsH3SQ+ysqjPSwCIhX82kdGKHcq5p7HUTcA43o49EWkluSgXwH+6
         X//4e4YxGLxUtyGK3T3SoWsajiB5JQrhVlL9GAt3vosSSG5aXVNzj7S5xzgszCCQKRSt
         Yj44YvX6I8uPDLSGh/51XvX6sXWoGIQmtM9rbR0tp936EZG8Mk2fuEik9y6X5FS/2puh
         zlH2+wR8Q/ybiMJMmdgPZvdzeg34pwBXw1K2wpe6skVfXFy6PUkHDa54zIJVz3KOoeeB
         RqYcTrtkPCin30/XUyL9jlWTmKzFaGYu9CIac/I9ZReAzygaBnvE8XRIGhdiXho8+oBN
         EJjg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796095333; x=1796700133;
        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=8QMxQ2EaiARSv9t79RMwUb0uHPjseoQ3LpegArnAN3M=;
        b=FZmfr9S6K0XmveNbVSTAmXh7X+2j3afCt2CgjWk79JUamVMZGZmZAovKCnqeDLe1YK
         VP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RcLM11nWb5XCWDe8
X-Received: by 2002:a05:690e:1907:b0:67d:b7ed:26d2 with SMTP id 956f58d0204a3-67df42b5a51mr12155924d50.21.1796095332718;
        Mon, 30 Nov 2026 19:22:12 -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.09
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Mon, 30 Nov 2026 19:22:11 -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