Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796095328; b=23u1ER5hPqGMDr9MtSLKx+Q88TiGWdKQLaz/qHUWFunZlvf2CqL7tSAB1FLIMzFr/LcC fnSWeo/zysjFVNn9UtWU2/X1D5zh7G1p+k1ZbSQpDsPf9TqgQpcHE2MqeyEtTI9JSawfG dB2JmLROegNqwWwu5z1/7wFYz4JoG0BrmsW6GIpsSLkNAghy6Rs9bFEszb143i9ODPB3N /fBc7ounTX+BoUjwq3Kr/38tVKzOa4AvicmsY7rDs1rRO152iSlMhkGZ1gwLpT3BiqyWw fGStd7vyp2KOia7owCxrg4Q4LKZdkdvQV1PUV1DRB0f6cnZLOQ8WThCVZc1UJK6ICEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796095328; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=bUcXBPcM9zeNJqlLfJ8sfhAwh5M7CteRwHj6fhGMp9s=; b=M9IUwCpeczX7j4JRu/qYAAnRqnb++8jHhhxYQHgvtg9wU+QG+mQIIYGlKzoFbzN9sk29 NstL1b/IxQy2eIJLo2sZOB6OZAKmaNmj+Qm0pcPLt0UFD45OpJp9BJ9swAWqy4dU2E8mL iwjjxvFsPDItsGir4/Vl/ZF762sOra6gE9YImHe3daLWaBHrFJRqqqDxnjh0hmLMsQy6S DlNxp4DojD9i9gw7eEeuZg9uAfny7cICBSgufO5SV0UTrvJ1n1PFiP6U8YluMwBV14/Hy QqGsL2LcHhwuIiuqUt+Zs6YAIOW0mMfb6WqZ3zabx71BXfFso+PIcGWjlJyA7P9tazQ== 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=b6SV2rdX; arc=none smtp.remote-ip=209.85.128.178 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 5DA42606A320 for ; Tue, 1 Dec 2026 03:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DA42606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=b6SV2rdX Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-8b4c685c751so101273857b3.1 for ; Mon, 30 Nov 2026 19:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796095326; x=1796700126; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=bUcXBPcM9zeNJqlLfJ8sfhAwh5M7CteRwHj6fhGMp9s=; b=b6SV2rdXXydSsxd3fpkYp5XCq2XgjECo2KkyV0lhndTeH9YS5uM4on7D/lPSQoEe82 vsMLjfpcDfy70iJZiiSQJdNG1P9QwxQM1y56bDdiVOPTS9cd1EC0vZAYfNcez2gTNp2d piUHSEtHlTHJNrs0v+JnZiDGbEtE6TMRDHKub5M8fMq03K0Xt1u4oyMpAkhir3px0col kVwUuGb0nkPcz2LmJ7hc/8lGBQ47UifAVH3tsAKehqQ+jKfJxNLqVJkcsRWbcnl15zLh MCiSclf0q6KO3tr4kqckFjGgsmYKqqovIqbgitobGzmhhs0AcY1O8JcjJge5RJFnXxmF eRew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796095326; x=1796700126; h=content-transfer-encoding:mime-version: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=bUcXBPcM9zeNJqlLfJ8sfhAwh5M7CteRwHj6fhGMp9s=; b=1ZcVZnuEfTT4zTQszlbrhFmnA6wAkOnWsCdSifp+oy5Q05ozOMDuEHeMrfeWOsigiH 1OHCT4O1BURyZwuZGH/k6+XvmDJjfsw0cGEnsFpcFnCf6SIY85U0Bpxs44SGUAaye06/ SA9Bg+Uslw2IEvrK755mOCXz0qUrScNsi3trK5C9xPzBSupLB0Pu6oUy86DDMg964CLe 0EdXWnjacaKRbUCLs4hrbf2cYeZcWrBMn1I/DMqf2lHNMa2PMaMC7tk04WN23ejsOYg6 A9xJVK+ydhqF9/QyNIKZHRe+wVhUmGTuSB/3Cd8UZCEPdnuqGZUSR+nLcyiMP1CuI6B1 v7pA== X-Forwarded-Encrypted: i=1; AL+hErEKl26U8fqzKr/aj6/1UzM0mPOByGlooEjrAg9GVVxvjK6pzDN+xN4vj0PkWptH3jzR06B6IQ==@lists.linux.dev X-Gm-Message-State: APuU4Z+f0n+Qaxxm1pvFhxr397jC6EGGeGSbzDQnrK51NcoyyuLASEUq eHrWzR3V14nfoeeJuiCNTJOb6ydAIRaW+XkIX5o+KF+N3gLBUb2HVeJF X-Gm-Gg: AZFdTZdQ3wTXbpQo3l2wepWFxPMwmuO6dmnGwz1z8ecCPcwR1jy9ulhdKv2C8JnXTQB cb4kGY+1WVwXG1JmedQ5MYLLUp57RxR8KRkgxs9mNhfotv8gs8f8m2usj5Byf7+0lXl2ji8lX1u zXeNJUUcUVPzClMjGO5okA0x7Cwq3oAH4UtxpXWApU/5BcGA1n0DBMZhvGyh3TIeZ50Iej0A5DM jF3woFxbtsrJxAsv8q5gagmoF2OugjMINszGxEcfY/MG6TBqtxdcvSLKIItStwzMmrjvDqYSTLQ P4al6X8xw4XQO5UKnJ9vgZf8CVvtnCH3cjuFKbvs4s0637fcusT3Wuae77TEdzl2sSzSI9bE+Vl g54HbeHGL2BN9toXsnipSKMcILLnoeKsf3cI173TGgxayNBEuc+fCwi6z1xZPYULhFyPYMduxrK 6nJJ/IYRut2T/FgWGTDUaxhTz/HdteyvCOngL1hNQlU6lR6/lV/U0MShKaXnbAIP23N02wuSYCI OhuXGiLgi1rFlCkxHi9Csx+yIN426BygvzG7YbSDRXSoImEXXUiV2HQIZcpkHTWcG9aXC7EkzhL 1xjwt0/lDNO5WYTwKhjLzfR8pxb1XAHiKZb41EQDRb9rI/JMWEFdLRhb5lRpckoOxYAN3fdgdQ= = X-Received: by 2002:a05:690c:9b09:b0:8b4:a39e:48a2 with SMTP id 00721157ae682-8b520436896mr142326637b3.21.1796095326339; Mon, 30 Nov 2026 19:22:06 -0800 (PST) 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.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 19:22:05 -0800 (PST) From: Juan Agustin Niccolini To: Steffen Klassert , Herbert Xu , "David S . Miller" Cc: netdev@vger.kernel.org, ipsec@lists.linux.dev, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Christian Hopps , Antony Antony , Sabrina Dubroca , Shaomin Chen , Roshan Kumar Subject: [PATCH ipsec 0/4] xfrm: iptfs: fix use-after-free by held and queued packets Date: Mon, 30 Nov 2026 22:21:56 -0500 Message-ID: <20261201032200.37030-1-juanagusnicco@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: ipsec@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit IP-TFS keeps packets for later on both sides: received packets in its reorder window and reassembly buffer, and outgoing packets on its output queue until the send timer fires. A kept packet points at its device, and through its SA at its network namespace, without keeping either alive. Each side can be left holding a freed object of each kind, which gives four use-after-frees: receive, namespace patch 1 receive, device patch 2 transmit, namespace patch 3 transmit, device patch 4 An unprivileged user can trigger all four from a user and network namespace on any kernel with CONFIG_XFRM_IPTFS; no IPsec needs to be configured, as the user creates the SA. The receive device bug gives an addition of a chosen value at a chosen kernel address, enough to gain root. On a configured IP-TFS gateway, the packets queued on transmit are forwarded traffic, which any host can send without credentials. Packets that arrive through a vti device also keep vti's tunnel pointer in skb->cb while held; that is a separate bug in vti and is not addressed here. 2/4 was discovered by LLM-based static analysis. 1/4 was discovered while testing the patch for 2/4 on a KASAN build. The other two were discovered by more thorough static analysis after that unexpected discovery. Reproducers: https://github.com/AgusNicco/iptfs-uafs All 4 untrimmed KASAN reports are also in that repo. Juan Agustin Niccolini (4): xfrm: iptfs: free held packets on SA delete to fix a netns UAF xfrm: iptfs: look up the device of held packets again to fix a UAF xfrm: iptfs: free queued packets on SA delete to fix a netns UAF xfrm: iptfs: don't keep the input device of queued packets to fix a UAF include/net/xfrm.h | 3 ++ net/xfrm/xfrm_iptfs.c | 83 ++++++++++++++++++++++++++++++++++++++++-- net/xfrm/xfrm_policy.c | 1 + net/xfrm/xfrm_state.c | 3 ++ 4 files changed, 87 insertions(+), 3 deletions(-) base-commit: 1213df0bc5993e479706c5eba5830243d778f164 -- 2.53.0