Article View: linux.kernel.netdev
Article #6344[BUG] net: tun: NAPI-frags skb can be freed during a blocked write
From: Cheng Yongkang
Date: Thu, 22 Oct 2026 09:06
Date: Thu, 22 Oct 2026 09:06
52 lines
12458 bytes
12458 bytes
Hi all,
In the IFF_NAPI|IFF_NAPI_FRAGS write path, tun_napi_alloc_frags()
publishes tfile->napi.skb and skb_copy_datagram_from_iter() copies user
data before the writer enters the RCU section that teardown waits on.
tun_detach_all() does not take napi_mutex; after disabling NAPI and
calling synchronize_net(), tun_napi_del() can free the same skb through
napi_free_frags().
A userfaultfd-blocked write makes this race deterministic:
writer: napi_get_frags() publishes tfile->napi.skb
writer: sleeps in skb_copy_datagram_from_iter()
deleter: tun_net_uninit -> __netif_napi_del_locked
-> napi_free_frags() frees the skb
writer: resumes copying through the stale local skb pointer
Observed on Linux v7.3, commit
08ab31164c55f20c7a2653de3186ae333470e2c1, on three independent KASAN
boots:
BUG: KASAN: slab-use-after-free
Read of size 8 in skb_copy_datagram_from_iter
tun_get_user
tun_chr_write_iter
Freed by:
__netif_napi_del_locked
tun_net_uninit
unregister_netdevice_many_notify
rtnl_dellink
The already-held local skb pointer also reaches kfree_skb_reason() on
the later drop path, making a second free a direct consequence. The
first KASAN report stops the panic_on_warn kernel before that second
report is observed.
Allocation/use must be serialized with tun_napi_del() and device
unregister, rather than relying only on an RCU section entered after
the expensive user copy.
I found no matching upstream fix.
The userfaultfd reproducer and full console logs are available on
request.
This was found with AI-assisted source analysis and fuzzing; the UAF was
reproduced under KASAN.
Thanks,
Cheng Yongkang
Technical Details
Message-ID:
<20261022090655.3643698-1-teel4res@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-350445-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-350445-linux-kernel-netdev=dewy.ru
From: teel4res@gmail.com (Cheng Yongkang)
Newsgroups: linux.kernel.netdev
Subject: [BUG] net: tun: NAPI-frags skb can be freed during a blocked write
Date: Thu, 22 Oct 2026 02:06:55 -0700
Organization: Usenet Network
Message-ID: <20261022090655.3643698-1-teel4res@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="171303"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Y7kMVNQZ/Q2LZ6EYOiO6tuGmGew= sha256:icQwze1/a8kCSRQ8Zdsadj0RpVPrlo7cwE1QJHHJJ/Y=
sha1:CiG9YOKxe7LU12VQsyd8yoBEVoQ= sha256:JwiTGTWkP9TGbi+WPaOMj1jF/NHpLCEoHIALv+Uztqk=
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 18DA91111E3; Thu, 22 Oct 2026 12:13:02 +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 5hSDGDfl9GqU;
Thu, 22 Oct 2026 12:12:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350445-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 D97951111C9; Thu, 22 Oct 2026 12:12:50 +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 D817B376CB; Thu, 22 Oct 2026 09:07:04 +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=1792660024;
b=3ovo0q6+DSp8MGDh7ydXuBTwAgvXxdz0pKssEnhuX+FN0QlxJX8L9huB3pZ6PbXAy88v
GRXyckqdnDy/SH1FRJw3TX+IbKwm22hAR3H6DqtmKhD0zX7E6urUHL2tlkDLi+skdsvNx
kXiFff5cFIe1Owur348KgjBRD7Ibra314atzSye0KQoUDTB5VSeFP6QnOnE5IBafSyL00
TnM9IqqftvCS6Ip8UkDHW3zLGhnLTLipKgaGyp2BUtmvj+4/fL78sL+gBCiwORiMJ7ajw
2zbMi5YwJfSDTTLGD3CAaLgvRcJrV5x6V4vq1SAFBbwsoQMDolDCyoBLQUCZS008Clw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792660024;
h=X-Original-To:Received: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:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
Content-Transfer-Encoding;
bh=P7oo1oMhPZVgU12iVwNehcOih+dQm88y3Gr1jI9txLQ=;
b=IWLtE+s2CO8RosPN2IVKeYWgW+uztAbskgWSvjoijmjzbEEwdKuoiDJdE9MDvu1/Ren9
XTLah6hnazYMG55k7+nzC4gS3QBkf3TRA6afid+LeaIHabaxQM9kqpSTSWz66Yq+tgJZb
PUf5T38pp4kI1ETfPzPC33eF6XQJ69T0p0BviOG9+LP0ekL0b0CDqGyCkiZDFYw4BnJAP
GHDVrhIkyBSm3MLLMXaGxxtS2tv35BLJBpsiKyhW4d18YIfqnXcwWje3OCSjMBoZT2AHM
+eDfYQSRxJ+Ure2/gEUsN8t9zHq0jz/FNAcf8RfRoKSJNDMaw02fFPEbbOEM1VdnnTw==
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=SDlc4RDT;
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 78B4D606A32E;
Thu, 22 Oct 2026 09:07:04 +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=SDlc4RDT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792660023;
b=djOIGEmuIdj2Hygrivp+1eh65EjcCP1JBiKEcOSSENS2MMla62nnS6ig+g+E8Q7wxlAl
1U+nz8DOdDOfudYKJANK4vt+mIqIPq6fQeIZ2n3eN5qlo5sPNxu69y8JEvRLG0+o92a+2
p8PCtLJME3mlsQNYT6Bcbe824dHIkvjLWG95WT7kNe/nYnUtY6O8ws5rOLQePvEiiFfRn
nibCjO3nCGT9QPv/6EJZ1cXdfVKslpbrI8nOblRIKD/zhoWUGtmiOVG8tMwnx9Hvpatua
x5bpOJTmsD2tZW1BsAWviFAVmmGnz4JL7cHyDDYHx37ePG7+4YGJLTGb0vz63HFVD9w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792660023;
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-Type:
Content-Transfer-Encoding;
bh=P7oo1oMhPZVgU12iVwNehcOih+dQm88y3Gr1jI9txLQ=;
b=5k2lMxmc2O6OQqkPiAz+noEonEWWWCmSWcAtGPBCJ1k06vidjrFQ8t6kdYK9rk0F6JKT
hiXewWZYhLCgHXICf6pOKH9Fq+4xGHfECTHzbtDZv7XIJm2pS8ZAi6puxuniN+TgN2IQC
2uRTDtlAOLroML8FUlglSJLIHgvtUDBRhPX5bYq+by3ev0lh5JskcDuezBAxBPBOysQdo
RuM1OXR8G5i+ZBRROPf2Jr3MDFvJGwQjHsj5oRK3DFOb7jklP/PcXH6W2jPUNoUnUaJ/w
J8nbNqslgu6IXqWyNBeFytSgTuVAAlrJitcz2Be8TzylXwSz5KzkAQIezqN+W0ggD2Q==
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=SDlc4RDT;
arc=none smtp.remote-ip=74.125.82.170
X-Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170])
(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 4FF86606A322
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 09:07:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4FF86606A322
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-dy1-f170.google.com with SMTP id 5a478bee46e88-3514b90bb89so4339926eec.1
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 02:07:03 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792660022; x=1793264822; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:message-id:date
:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=P7oo1oMhPZVgU12iVwNehcOih+dQm88y3Gr1jI9txLQ=;
b=SDlc4RDTSZy0axDlx0XPE9JP8KPepfr/VELQcYuZZs0JxutnADd4eo8MI475qp1seB
kXoGILCKB9uMH5+BUb8KnyBNSEtlSQ8/nhPrQYiRlQ2xZuL+rTp5Ulmtas22mQpN95NS
8ra392nzpxtVI15SDPAvp7ww4zcIhCKZ0UKijmHP9Ohzpfxyy+wlD87RlQBsze6iqNmz
C9DdMeafkr961E/yjtMAzdzIqjnYBxQx2g2vf+ZfWyyhyufZk3oToT+wQePaewf1HR8U
RMBTSz3e/vuJFBnrzhX4emvGhk5XYCWMVzqPpug83ZiqyUPWlMU3WVqqC0wHdQEZOSNS
kzbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792660022; x=1793264822;
h=content-transfer-encoding:content-type: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=P7oo1oMhPZVgU12iVwNehcOih+dQm88y3Gr1jI9txLQ=;
b=iFKmcaeLvTa2MoV/JV6WVwdEM+vCuN5gaQNTr9T/M8L/R26rnaD2Ax+NyU6eobLXAE
SGrdSsn6md6aDEtl2rlW9rWNJS+gzfYYlpJ5l7ElUtd6JEj7MDGsBPKykZZP18A8JGFK
w5CTBhfGIISQM2JXS+fqVEsDYrCR9BviEEwEnEUZ8aiAiXMFBuiKC0SNlstCA45TTbpS
zjbV7dxoX5mfmwNFIApAAO0M8/bJqVA9hbIAqW50/03dCVa3HDx6CVkXg7wF6KsJ/Yeb
GZvpprbeR0/7PMWAhuhAzei9TIf4MQT6x63LzlOR7jrzrzc4H67s5w1s4bfCdkHgr0Mf
ZzTQ==
X-Forwarded-Encrypted: i=1; AKwUvBwMqpGIehMcjL2VkWBWg6OSd21NVagmn8DN740XMwc++zPvlhY+bw1aRoGSmuRstzHOpNpSHRM=@vger.kernel.org
X-Gm-Message-State: AFq9FYKcMtLezA3pqKxocmwVaHSR3N0w7bh1uI7MKdB6/9iUMU/0KZhV
0YAFvXFF3k5ThXe+A6fRWWCdeKc7A30poVBkm/DfYh3I8HaG0IuO7QUX
X-Gm-Gg: AYBFou3n8Mg7b+U8YKbOzmLKiE2deTAMh5vQTSdgVt8+o/9GdmanZvvqtf3C76wRACM
qgNToMPfDb/GjyHaZaluO0IWbm0LNDY5tKC/gOsbW5p+FCzeTBr/wMpCT/lHbXQgiUwKZ2HNgok
ti3nvLd0f2/8faNgHlwVLqYxsvNcwnoWZo3QbKmdkSBpQ43MS5H5gs3nU6qD5Q/HoEctjvw++XH
Mb0ZwoGbqhG78+kThgPM2lyUgeyLbgv4mx8xbQv9lptrVPW5Cdf1V5AS+sR4Qn2Ia1jFXhVl8e5
q+ufxZAMa4IeTzWDUxjvxp2y/vx5kaz60PbLtvxZIg/d8Xj9gaRfsqr7ODSS4ZfVcXt3MHjTznr
JdvaeL3wn9a750IAEJf/7BcXBT1EaxLLKO8BHPbIYIZYuIhIAdshiA6Q113aOaT35iPfln506WK
3XntlROPkCMS9T1u8I45P/SCC8odkNRtmKkpXqJae9L28ugBls80t4qUO/QvhuGOt4ykEFnzBPT
YLZ7FQBptfJotwJhzdctdBfd7UGszI+EZ8RJyVor2GYpm2y/2IBpXv9qNMeiS6Iv6xulgNwwYvZ
QPxDQB3w79oTE6YBVJw=
X-Received: by 2002:a05:7301:1c82:b0:35c:6268:8127 with SMTP id 5a478bee46e88-3674c63d952mr6066086eec.13.1792660022183;
Thu, 22 Oct 2026 02:07:02 -0700 (PDT)
X-Received: from youngkk-vm.localdomain (67.216.200.102.16clouds.com. [67.216.200.102])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-367416a1fb9sm12794808eec.20.2026.10.22.02.06.59
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 22 Oct 2026 02:07:01 -0700 (PDT)
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.34.1
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