🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24947

[PATCH ipsec 4/4] xfrm: iptfs: don't keep the input device of queued packets to fix a UAF

#24947
From: Juan Agustin Niccolini
Date: Tue, 01 Dec 2026 03:22
53 lines
13248 bytes
A forwarded packet reaches iptfs_output_collect() with skb->dev still
set to the device it was received on, and waits on xtfs->queue without
a reference on that device. Without the queue, forwarding runs within
the receive path's RCU read-side section, which keeps the device alive.
If the device is deleted before iptfs_timer fires, the packet is still
encrypted and sent, and ip_output() or ip6_output() passes the freed
device to the POSTROUTING hooks as the input device. A rule that
matches on the input device then reads the freed net_device, and an
NFQUEUE verdict takes a reference on it with dev_hold():

  BUG: KASAN: slab-use-after-free in nft_meta_get_eval+0x4b4/0x600
  Read of size 4 at addr ff11000001d120e0 by task swapper/0/0

The rules that read the input device are the namespace owner's own, so
the freed memory is returned to them: "meta iif", "iifname", "iiftype"
and "iifgroup" hand back its bytes, and "iifkind" dereferences a
pointer taken from it, which with the memory refilled reads 16 bytes
from an address of the user's choosing.

An unprivileged user can trigger this from a user and network
namespace, by forwarding a packet into an IP-TFS SA and deleting the
receiving device before the timer fires.

Clear skb->dev when the packet is queued. The outer packet carries
several inner packets, which may have arrived on different devices, so
it has no single input device. POSTROUTING rules no longer see an input
device for IP-TFS packets, as for packets from local sockets, which are
already sent with a NULL skb->dev.

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_dev_uaf.c

 net/xfrm/xfrm_iptfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 320de30ed8bd..0fd3a295d5a7 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -1834,6 +1834,7 @@ static bool iptfs_enqueue(struct xfrm_iptfs_data *xtfs, struct sk_buff *skb)
 			IP6_ECN_set_ce(skb, ipv6_hdr(skb));
 	}
 
+	skb->dev = NULL;
 	__skb_queue_tail(&xtfs->queue, skb);
 	xtfs->queue_size += skb->len;
 	return true;
-- 
2.53.0
Technical Details
Message-ID: <20261201032200.37030-5-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-374679-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-374679-linux-kernel-netdev=dewy.ru
From: juanagusnicco@gmail.com (Juan Agustin Niccolini)
Newsgroups: linux.kernel.netdev
Subject: [PATCH ipsec 4/4] xfrm: iptfs: don't keep the input device of queued packets to fix a UAF
Date: Mon, 30 Nov 2026 22:22:00 -0500
Organization: Usenet Network
Message-ID: <20261201032200.37030-5-juanagusnicco@gmail.com>
References: <20261201032200.37030-1-juanagusnicco@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1601946"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WE4F7wUgczvC0OvRpjhelALpe0c= sha256:WQC+oBQwpXFOHiD1uzI7wEK68SnB5gfOfg2Y+6eK2Is=
	sha1:j5j+pGT6CezAO3GriiNArw6H23I= sha256:67KbGR5bgQzmA9W5IUT7gyZQsg6o9HxPRabQMXt1U+U=
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 594CC117227; Tue,  1 Dec 2026 06:22:36 +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 zmjZ_Kq7aaDi;
	Tue,  1 Dec 2026 06:22:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-374679-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id ACFF8117225; Tue,  1 Dec 2026 06:22:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id EDCA02359E; Tue,  1 Dec 2026 03:22:21 +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=1796095341;
	b=dVFZj3WMoVCcByylW4FohJVFcCrbAuAYNxUx0le0IOcki5A9m+oZq7BThCGd8nC0+LyR
	 +eDxnEmJWWLDXvipp8sSXfkLL6MAFfMD/OpJxM+0WUQKLjXyjkDwxf5BIBQFkn8XklgPU
	 5/qK80Op6Pobv52IzRrsxt1w0g9qootbIIc9e5qecZ/jI1fXcUSM649WfWBBoepBXOZkN
	 HN7ZqAVCDIFOeQpq1I+RpuoYwYstpHQIFrmXTqrEXKb1FwDpNyoZJvRwP1x/lmq5RZJqf
	 6j4XKzJ94lfOMnrJgP4CaPttb64Rrz/TDKxiQqEWz1k/Pn/cfTtkRZPFqhjnYZKABMQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796095341;
	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=3E9Y0L8nw2lXstZZ+QPNvubQAIGJ1jZ3vH0rK2KbcSk=;
	b=p/zmcnvqjSDdsst9Ijo/JZzMrvhJOfVw0BFDWAjCwxQPEvA/zBi4PkhmMDhkoCMiJqdz
	 +ohQg1HF6wh/eseNC9cZ1UV+QZBwdvthO9ftF6eB+kF+0uiASAnO27M0njT9gdtOGcx7r
	 MvZuu003SWauuiC1ETlFgVv+y68y/RrnO180UzbbAzUWgR/XcnxYg1p/xC7x9cW6RDS2v
	 yz7Wdl566uduSE/qMiRMVyrFkMQ3JjrOGDQOG4AFdEZ/2C4UU4MSucwmdDDUOowMSEHXM
	 KVNo648pV8K0LkAARQs97fNya5pKtgesscOHUAwuYbSS86ZyVWuHVYNeQ6qKjpSdl+g==
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="qfO3ZF/b";
	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 49864606A338;
	Tue,  1 Dec 2026 03:22:21 +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=qfO3ZF/b
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.53
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796095340;
	b=JuLWAmNVwXOAvju4KuPLc3pZUmksx6BUWZA6OuafIfwtaZn4KoFApFgpOhNuAtWK+bvQ
	 dssKlamQzWa6PUUeCIjvELwY0krTpKMKgaHbuGPr7KOZHVK7x/b0t6927zGJ8iWVzkaa7
	 zICiGJUsT5AAUdFfLFUQab9Imnn3ipq8UoD5nqLNXZhRBDWmGh6Fkf4NGhmb4lpY8UucN
	 HLgbB4554bUHeEgNqEaW4ijg/6cHyUJEGqN+nPAa7XK2ZlntBXTspBt6oBUmbjILlmllZ
	 5OYQFNVokXQBwxOHcpOAMaj1sBAVHgmKw/HkzcH/X/TcpJBT1zVxGnOQEvikLK5ZzGw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796095340;
	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=3E9Y0L8nw2lXstZZ+QPNvubQAIGJ1jZ3vH0rK2KbcSk=;
	b=nQ1jJzQ7vAMAtHBKLdVjfTlEMgMOxPh/QrJoxCeEbkHA5Vv0wHkvsHAtOYnUvOW3xkbR
	 TZicAxkaYT/bVknwGR2v35HlDYrcYZRLEjvtEgUyBijTXwkf6GIofu0UIGiJDaf7bSDf1
	 IXe81rwf6R8JkWc+OB91A7Ip1GFx56W9XMrh60hJPbWOM6c/A5cpJeV1wtBZqK9pW900E
	 sL7PCdQmCjjsGAOAtkci/GG8RgbHfxLLmhWmOyGrQ2nwwF6CGBYvDlDbKxvbn/LKWxr5r
	 dcDpSChAutXjDCSzg6kfdQgruf8UmWxF7JrqtRGV92T7uZIHRMHYyna0ik0NQxapiKg==
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="qfO3ZF/b";
	arc=none smtp.remote-ip=74.125.224.53
X-Received: from mail-yx1-f53.google.com (mail-yx1-f53.google.com [74.125.224.53])
	(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 5AE41606A325
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 03:22:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5AE41606A325
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-f53.google.com with SMTP id 956f58d0204a3-67df3b1ca06so12638182d50.2
        for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 19:22:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796095338; x=1796700138; 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=3E9Y0L8nw2lXstZZ+QPNvubQAIGJ1jZ3vH0rK2KbcSk=;
        b=qfO3ZF/b+hjFNv2dOdaGcFNrE7RZSLZ/ug7F0/HrRaaHm3/C2umeNsp1w+gX4Npfg0
         Of3WeZQmuHzxuFlbBNGKzKJy/w907FuTgtx+pVEzMJ+aCi4iG1ELVGQ6lnmByno2fQpL
         eUa2uVW2FyoXMs33YuZKWIEYKEAQ8+Qv2G+wAx6D4h2iBD2r0KFjTvJaLtp3lFmX1mfd
         cf0+XnD5iiv0/eEQkY5gEHq2umSts26VPa/TVEhGjnhTToriFqMGDDs1wx1oaCrIX1Pr
         LMUPjtlWNyLtY+sCzqhmw+TPZ1ND9derbLaiPJHik8flVJl41Gp36OuA4c5ScR24b7oV
         WL2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796095338; x=1796700138;
        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=3E9Y0L8nw2lXstZZ+QPNvubQAIGJ1jZ3vH0rK2KbcSk=;
        b=HpNXzZKZltq+vtY/9ZixOw8qEXSH9Jjqje7JIAD5xblC4mlyEI8nNradNORuKa6peB
         eHVlcuX+so66RouUZZRja1k76Zs5FJc/M2ky8PqkdBK652DiF4SPbTqV0Dx2msIL2EGA
         2YiYvkPpg7aOw/dQSK5qNbSqqnczXHfNmY0yzR8AUW0vT6GQxuxUFBjv+0oXFUfVpbDb
         yGEhI66HfW4i1jpyTR18KeWhoosbRgxdL/3QQpXMvBXLAIbCc3KPFrGfKTBebFszjUom
         /frxBpZfENS50SnLSf3Gm8d2l3YQa3Pri8CJu0nCqNZ4NbsJVcqHh7N9x53nDX/bxlSm
         VnNQ==
X-Gm-Message-State: APuU4Z/IA3+mST8xgxWlj9tAYGnLYZ+Zeoyn2ESRVj9LbZ92lM1aqcsT
	Ii2DFl2Mg1Tzn3Rc41GuN4jTNO8XRzfV5leHwxXemkXxSzmsxFQIdhv8
X-Gm-Gg: AZFdTZdqHMW/RYHfziQ8i9V5qj700dU9yFCNqFSawunJD7woIHzl8LJj/fhAkEaBNGL
	5hWNNvJ80IN+Ebl0InByrJS0+XzoN+0X8W8r2fpVV6a3nx7UE1kvhpEsUjnOyM8qjP/P4R//SSv
	BTWrvUm/IJPr6HDWAr6tMaSyK+Zm3K9KSNjzw6tTVANtZz46F/y9TfOAuVCSotzttS5A3yE3hxY
	FNm5lRLfHil8lc4c2M/2OKBFhR9GBf1rBSDP4cSFQkmVz1x/keP2denIJafhOwUSApCW1wWIZu1
	TWsDqwEIs3nzXlgkjRU1tO+ALFR3iJUQQg3lXBRF1IOJYmqcuy3EBverYSXi4nEkO25/USN43xy
	tthDCAO5SkWwg6NWS/t5YKCMsIG2o4E+DpSR1axXkfcrJHU+L7uVQo63+2/i73j9l9Y9rBw1fLM
	38PXYvMpddLv9tTqiU0mMaBvFv1j0l1TtDrNRM8h+njxyTUM8kSlDjbNuNfCs7Z6kBz+VkqiXXd
	200rTbkBwHd2xgqdJbxL2XvXWpVShkY8JlpAvn4fqKme8wdxXA1meze3GRexn/JpDHPczC7GCaZ
	nxUsP0a0o6HsulaihCdcjVlValIUCCYue9DwUliYakQ5IiwQBoK3
X-Received: by 2002:a05:690e:13cf:b0:67c:17fb:eca8 with SMTP id 956f58d0204a3-67df43d06a2mr16960137d50.32.1796095338374;
        Mon, 30 Nov 2026 19:22:18 -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.15
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Mon, 30 Nov 2026 19:22:18 -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