Article View: linux.kernel.netdev
Article #5040[PATCH net v5 0/3] xfrm: fix vti tunnel device use-after-free across async crypto resumption
From: Qihang
Date: Mon, 19 Oct 2026 15:32
Date: Mon, 19 Oct 2026 15:32
87 lines
14643 bytes
14643 bytes
This replaces the earlier vti/vti6 series and the reference-transfer rework. vti_input() and vti6_input_proto() cache the tunnel pointer in the skb control buffer without taking a reference. With async crypto, the receive callback runs from crypto completion and may run after the tunnel device has been torn down, causing a use-after-free when the callback dereferences the cached tunnel. The input hook takes a reference on the tunnel device when caching the tunnel. A successful receive callback leaves the cached tunnel in place; xfrm_input() releases the reference on every exit, including after delivery and on drop paths. The error callback only updates the error counters, so the common drop path releases the tunnel reference after the skb has been freed. IPTFS, which can free or consume the outer skb itself, releases the reference through xfrm_input_drop() or xfrm_input_consume(). Patch 3 relies on the first two patches: the receive callback must run before the async skb->dev reference is dropped, and the address family must be available on the early invalid-state drop path. Changes since v4: - IPTFS: when an inner packet fails validation, __input_process_payload() can reach the drop path before the inner packets queued for delivery are sent. Drop those queued packets as well so the outer skb's tunnel device reference is not leaked (found by the Sashiko review of v4 3/3). Changes since v3: - the cached pointer is always a tunnel; the address family selects its type, and a non-NULL tunnel slot denotes one held device reference - xfrm_input() takes the tunnel device out of the skb before gro_cells_receive()/transport_finish(), which may consume the skb - the device reference is dropped only after the skb has been freed, including on error paths - IPTFS passes the state's address family explicitly instead of inferring it from the secpath; consumed skbs keep consume_skb() semantics and drop paths keep their skb drop reason - drop the xfrmi changes: it re-looks up the interface and does not participate in the reference transfer - merge the reference and IPTFS changes into one patch so the series remains bisectable - the gro_cells NAPI window is pre-existing and is documented, not changed Runtime testing (aarch64 QEMU; KASAN for UAF detection): - VTI async success and error: RTM_DELLINK completes without a KASAN report; the unfixed tree reports slab-use-after-free in vti_rcv_cb. - Async resume with the SA deleted during the crypto window: the reference is released and the device is removed; with patch 2 reverted, xfrm_input_take_tunnel_dev() warns and unregister_netdevice() waits for vti0. - IPTFS outer-skb free: RTM_DELLINK completes; with the !first_skb xfrm_input_drop() reverted to kfree_skb(), the reference leaks and unregister_netdevice() waits for vti0. - IPTFS aggregated payload with a valid first inner packet followed by an inner packet with an invalid IPv4 header length: RTM_DELLINK completes; without the sublist drain, the tunnel device reference leaks and unregister_netdevice() waits for vti0 (Usage count = 2). The IPTFS timer/reorder/state-teardown paths are covered by code audit, not by dedicated runtime triggers. Previous versions: https://lore.kernel.org/netdev/20261018090638.55686-1-q.h.hack.winter@gmail.com/ (v4) https://lore.kernel.org/netdev/20261013074610.17808-1-q.h.hack.winter@gmail.com/ (v2) https://lore.kernel.org/netdev/20260930090813.73901-1-q.h.hack.winter@gmail.com/ (v1) Qihang Qihang (3): xfrm: run the receive callback before dropping the skb->dev reference xfrm: set the address family before the early invalid-state drop xfrm: hold the tunnel device reference across the input path net/ipv4/ip_vti.c | 3 ++ net/ipv6/ip6_vti.c | 2 ++ net/ipv6/xfrm6_input.c | 3 ++ net/xfrm/xfrm_inout.h | 4 +++ net/xfrm/xfrm_input.c | 63 +++++++++++++++++++++++++++++++++++++++++- net/xfrm/xfrm_iptfs.c | 42 ++++++++++++++++++---------- 6 files changed, 105 insertions(+), 19 deletions(-) -- 2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261019153247.89957-1-q.h.hack.winter@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348668-linux-kernel-netdev=dewy.ruShow 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-348668-linux-kernel-netdev=dewy.ru
From: q.h.hack.winter@gmail.com (Qihang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v5 0/3] xfrm: fix vti tunnel device use-after-free across async crypto resumption
Date: Mon, 19 Oct 2026 23:32:44 +0800
Organization: Usenet Network
Message-ID: <20261019153247.89957-1-q.h.hack.winter@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3671407"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8ioWFWdBoHNyH6YQtFSwcWYDZUw= sha256:8Nvl24F6t0w842cPMuivBDT1jF8iJUVTjOinUQf0K7E=
sha1:dGFPKnMLSUIwDpD5efSaxbtXA+Q= sha256:HOu2g6snb8EDmXNzfyohiOCpDr2OVO2a1RiOChDNLhQ=
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 511A7110A6C; Mon, 19 Oct 2026 20:48:07 +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.25,
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 7QUsxEMC_oKl;
Mon, 19 Oct 2026 20:48:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-348668-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id C396B110A96; Mon, 19 Oct 2026 20:47:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (aws-us-west-2-korg-listserv-alma10-1.taild15c8.ts.net [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id BA69DE3914; Mon, 19 Oct 2026 15:50:52 +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=1792423980;
b=m+oaPIHSzFYQBTG+PX4CNNItv3KwClBP3icYSgDwt1ilhqAla/NQPaDqUpm10/uP1OPc
OqhvgF0+PZPz2s3ZE4FzKocF7UKTTrx8WokEqBEWRJkJCHXNjXbplD9rRsO4ROqfSZeNe
3MXTnjud5mk7Q3lQ6yA7dguVWGqe0mFNe4ZR99FRWWmfLcUcNqaURsJ7wjld57xYvP/N2
fLRstK7m1Jv/5renVesr298CV3CE9BbRJbvMr15kDYuUhX58Jk8OSZf9FqAxROGuygeN6
5BU7FrcirPNGpoGN++k+dxPOQ6PldVtJ+CM7c37ic6hJCaNkogBQ06BNTolR7jNmlRw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792423980;
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:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=ygIty8U4Oh+xEsvVfMJ67KbyembTcOkF0IMJVfaJF8U=;
b=u8gDX+y8sSeotYldSDkXEzdi836UenDETkwq2+f+zClmpTBybVZ/HkcAX0rlKQuekI9r
7CDl0V3VsWlQNuwVqxEve2ZH16zl5VeKwos3wwByBkhg0BO3Cw1TdmNNJwVbRIJ3vO/KZ
1jDYhl7Zxz23zN/cwRoI2fpkuP14wZ3n66gqYpfFACN0dER64I3cuV/qDxXURSPg7NVfp
3Ch9+jqMq23Ts7Kv3JbTywVMxajoKq/Y87cHSViiiGliwsWImb11sS+6QpF7yuw+AYbiG
TNa65i2WiurD1xc9uug2ajuiWzSkwSX0Jx/043WVKy0Sia8sk0HiYPOwWs9m/Zob1Jg==
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=20251104 header.b=ViAwuJvu;
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 374A8606AAE3;
Mon, 19 Oct 2026 15:33:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ViAwuJvu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792423979;
b=bxZYVysZtrOMHfJfnVWYCxPwPaqZDrBo0rmte+4HCBo+YgbbHHbisK8ZzNbL88JBOxUf
0xGlTvlqQbjtf4VOetK+WzJxnl+zmy2Q0aMMIvF48Z/vSUPkm0qTABokhv9orZ8EtNv+M
HkrC/BUW8A/6x13XNJZN0hd8tcPuTPgbLsY7t6LWdKjvGYpBsUD77Iq5wWIS+s/Geo7dY
JzjSTY17oW38jepjHTZ3lWt+xpMhqBj8GyEA2b37wDfkXjFhIUAPNuJsyTWqo8BzJT6Ht
nJTiqXHR4iyBVn6Rdl4SE94Nl6Na184UNjsrTV0LEGtuHFwhTEoAPaDKcfY8Q8Uygbw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792423979;
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:MIME-Version:Content-Transfer-Encoding;
bh=ygIty8U4Oh+xEsvVfMJ67KbyembTcOkF0IMJVfaJF8U=;
b=nid+WwwasMnmXZaLBUWcwG7KXTpBdEEu7OvWQRn0h/MPuP5MgU8D5bLkqbWlAKsNQk2C
JRf6uOp2kICuHV89/Oz2QKQhkl6N8X6Wr3hFsm/Poqw20gH0cPP5evid+T9TTAtMeYrye
0mmmmWKpuv0vdNice0lap43ZadMjH5SiSLjoVEj38gtlRsPe+hM6DzP4oSaUDS/UIyOxG
IryxFeQH88+BfWxoxhrRpRTuInsLQl7hI4BlldrY+xr0Yc7l64H1FCbWof+SnHLNkh+qN
06WVdt+tHkq7/MLcDnb53zk7tRuQtloyNphN2mBdIlRbmj35ipBacOSmNHX6vXFIsBA==
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=20251104 header.b=ViAwuJvu;
arc=none smtp.remote-ip=209.85.215.178
X-Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.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 083F7606C903
for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 15:32:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 083F7606C903
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-pg1-f178.google.com with SMTP id 41be03b00d2f7-cd06e1a9d16so111178a12.0
for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 08:32:58 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792423978; x=1793028778; darn=vger.kernel.org;
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=ygIty8U4Oh+xEsvVfMJ67KbyembTcOkF0IMJVfaJF8U=;
b=ViAwuJvuJNS3lPnbcEqbXbBxon4y5zd/k2I/OZW6XWgxcEyhQk3+ztZymplTonjrs5
/RJeOzwIusIHemZZbaTWEkYbhFtxowq7pdFw+QhUOZir9JT2BIzImWIgmeVQkMIQRgGB
PvxVG6KX4MPpuO08nYcRWnSjlH8LGQJsyHqbaZOSC1jKWOxrsMc5vcEdfNWWqaoNe7GZ
BA1iiqBhnRz4rh1miPyDJopAnnoCfHj6QW9NDEXo4vCbNuSheFNp1w8tHAV3jzDRLh84
GARCA5IVGqjzvNqToWhW8FG5U9v0Q0Pi5ZhLv4s29cyEEdYN72lkZ8vExXWfa438rQK7
L2uQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792423978; x=1793028778;
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=ygIty8U4Oh+xEsvVfMJ67KbyembTcOkF0IMJVfaJF8U=;
b=SQClt+Z1WuPC6Yr+iy/oRb8ase0o00SnCcouoY2jZ1Kiqh/GEEU9K4MliHtN83YrJc
bt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637.2.1792423978219;
Mon, 19 Oct 2026 08:32:58 -0700 (PDT)
X-Received: from localhost.localdomain ([183.42.136.236])
by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-89f57452b16sm4017801b3a.29.2026.10.19.08.32.51
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Mon, 19 Oct 2026 08:32:57 -0700 (PDT)
X-Cc: steffen.klassert@secunet.com,
chopps@labn.net,
herbert@gondor.apana.org.au,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
dsahern@kernel.org,
idosch@nvidia.com,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.54.0
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