🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19365

Re: [PATCH net v3 3/4] tun: clamp zero-copy copylen to remaining payload length

#19365
From: Willem de Bruijn
Date: Thu, 19 Nov 2026 21:13
30 lines
12214 bytes
Junyoung Jang wrote:
> tun_get_user() also derives copylen from hdr_len or GOODCOPY_LEN
> without bounding it to len after removing the virtio header. A
> padded header can make a short frame cross vhost-net's zero-copy
> threshold. tun_alloc_skb() then reserves more linear packet data than
> zerocopy_sg_from_iter() copies, and the uncopied tail can be delivered
> to the network stack.
> 
> Limit copylen to len before the NAPI fragments and skb allocation
> branches. The requested copy length then cannot exceed the supplied
> payload. The normal skb-building path is unchanged.
> 
> This matching tun issue was noted during review of the tap zero-copy
> fix. An AI coding assistant helped prepare the /dev/net/tun
> reproducer. In x86-64 QEMU/vhost-net, a 14-byte input produced a
> 128-byte frame with a nonzero uncopied tail. The patched kernel
> delivered 14 bytes, completed 300 repeated short sends, and still
> selected zero-copy for a later 400-byte frame.
> 
> Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Fixes: 0690899b4d45 ("tun: experimental zero copy tx support")
> Co-developed-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
> Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
> Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

Thanks for converting the original patch into this more complete
series.
Technical Details
Message-ID: <willemdebruijn.kernel.10e4a96974af5@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367319-linux-kernel-netdev=dewy.ru
References: <20261119144241.360238-1-graypanda.inzag@gmail.com> <20261119144241.360238-4-graypanda.inzag@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367319-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 3/4] tun: clamp zero-copy copylen to remaining payload length
Date: Thu, 19 Nov 2026 16:13:22 -0500
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.10e4a96974af5@gmail.com>
References: <20261119144241.360238-1-graypanda.inzag@gmail.com> <20261119144241.360238-4-graypanda.inzag@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network; logging-data="2981701"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3NJsA9udOnJrHe3IhKJ44ZxnQ38= sha256:GfseH3QqliIYjGbb01HvYVzKdmrm7Tk/m6BKkFMzo80= sha1:748t3H3Lv1PdXRDwybNG5swJ+d0= sha256:Bb635uQOzLIoeITelTn4wiS/svawyw6yOR9GgWowk3A=
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 B249311577A; Fri, 20 Nov 2026 00:14:00 +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 wxFzkBBCac0h; Fri, 20 Nov 2026 00:13:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367319-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 979B4115752; Fri, 20 Nov 2026 00:13:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id B520E186F04; Thu, 19 Nov 2026 21:13:38 +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=1795122805; b=Kb8RcWOMkhcWxfP1q7wRN5h9Na9/B2m/0U2tjcABeRGSSTKUx6BtFCE/2FGxruT7DLpA 9UWeGomWZXbfzPvtFPq5oLjkmDF98Q9FN+gTufHSnQQ3r5Z8rtEHDmZ9R+0fOiqs5qa+K TuDelvLGcMMA812XjYLgi74kcJsP9Nrsi5yKzwJGPofH3GODjY5XPru0thxnLUC0T968w n083JuMysOFCUq95r3KKUye0ukL6YTH5NaXMF4qCLgqJQFrFU+HQ+HrVKxfJ4CSlP/Q9g HGmvYTA/HDFywuMH8xU63SyC7Ps1CtH5H/m6Gzz3H8quFo2514u/hKAuB8n5X3GDKmA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795122805; 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:Date:From:To:Cc:Message-ID:In-Reply-To: References:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=7uQtFNOdQLFaDhr2O+xKsh0q3GABDuv111m5QXQWzZQ=; b=dhgCXMI+11llZw6czTi8lgsuScUl+De5/ArVslMlWco/Rg9l2Tp0eQXL+/SC2KyaW+vE 7jSvpFyqQFx60A6Ur52nVELtbCzFKDdgrRoZmLxG1Lzmfkn497TLHN4MAyCpQzdXpwSLY st2caVU/XvDLibOVOR4N98SBtEv5hHaDtUWDn7925ZDwsroIXBU4kv+c1+C0tDmY2q/H6 zKqUe7w3Jz4S60p1Hf/6GyU+bmXmnwH4I+YfjKNHWZaNZCCcgUJtL3Sc+q4uKPdwEib+R v6y6kBBmRuXYDI2hBVBioKANu5Ju0CFF3SNu4yUVCnokyStvpLyelhE3S6gI32Q7g8Q==
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=uWExxlHe; 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 7E64260A2608; Thu, 19 Nov 2026 21:13:25 +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=uWExxlHe
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795122804; b=ABXgJnOmmOfHP+/IF1Evif95tHFyi6sI+73DjIjRVLsXTnrfvv34ZxZaVYQd5YaYjPdS CcLuxs8WFB/4XSxNU9gVVUV9W8QdxjXsWP43DDsRQAnw0vC52isKy9qk07jB66veU6Uwz KluF8Bs8MJlGtAHR9W1bFJiFSFv86FnQ3S0fAfHg8KMqq/QSCawN9lex6iK2Spb5gQUWA XuSG3qmxpU9zcgkSe+O+BUXwJg+B3A6YH4xzWa72OU+eOzrZFpeYqxZHZgMsPjUnCNZdr 3YmOiJzTkm9NKemG+rEKTgVOCLdL35FR5Uh5tkuiCyZxfuU8iuxj3cVD6nVVKjh1/uw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795122804; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=7uQtFNOdQLFaDhr2O+xKsh0q3GABDuv111m5QXQWzZQ=; b=P2/Xly/XWz9XJPI7kJDLTw4JOQlAcBFyCexpJSOLBTpDR++DuqE2yACxigMI41d8khMr IQAOeMOqcGkPerZjhO5t3lBquyUrkTQGGCKJY8N/Nm5rGeb8+sDHNIClV2D7qsyluvnyz ILmXv8od+pI2g0bOTlcB9avEnPXGY3JtmE0nz3jsYgV6essHc0Np0MuSk68DdFNmcpPQc nO4CuNT2tjpzGdvgkTt1HU9kmAnzQ1gduJk789pqoAT8V2m1rLegFz/ttXsA2bk/6BAnN bV1c+KVJxxKUDJhadKj4IOzI2eBN42M+A4hUh9XtTc5yOObNJCRQpcGkJ6M/2Kaeyrg==
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=uWExxlHe; arc=none smtp.remote-ip=209.85.222.169
X-Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 EAF4560A2628 for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 21:13:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EAF4560A2628
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-qk1-f169.google.com with SMTP id af79cd13be357-94959217274so30318885a.0 for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 13:13:23 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795122803; x=1795727603; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=7uQtFNOdQLFaDhr2O+xKsh0q3GABDuv111m5QXQWzZQ=; b=uWExxlHej4/g5IMBDYKhLOiKScIXVgK7/fzcH6uPm4B7PWN6GBFYe8hLUAyEn/NR/D yWcZtnkEjJ0B8q4SuHNDLDzaH58ZES6SCWCQz3EtIbIU57241Vop9zAETRC7e6LQ3ZuV GF+4KVNXMFPHAXcHx0kX8ysOznPl1EvWT9/s9gNB5ipWmFBgsNkdKIZnUP851RUyZCW4 kIPK6Lzz1uETDrMf5HGJ3fBJpQ3RjWFS+k4qDmvFEItO41oRuGxzP8ToDnNKyGeaGyRL 4HSoVGTPB0wHZ6o1DvkxzqkBZmEmmbYNTXgolxI6URnoVyGnEoZNDh+N9ssbSozCj5dm 19Aw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795122803; x=1795727603; h=content-transfer-encoding:content-type:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7uQtFNOdQLFaDhr2O+xKsh0q3GABDuv111m5QXQWzZQ=; b=Zt8mawOdrYeadGU30KyBPzQDrgZEXx+eM1bgWE+N7RzEaPdqP/H6gOfECljhWGCBal jrcMcF9gT6kpSx793KooqKorXUBCUlEgRy7XtiWjkLSL9paLKeTK4efnQ9NGDG78t5rE vkpGZlG5+jx0J4s2dNCYNzeHLIRnEmZwroW13/0U3S52qO8ACiF/Fr4HAlSEDj4NuUd4 GvEGPtt14TUYVugA/Q1Dsd0pN04tBWXFihu9ctO41agWBAbps8zsNshl0f/C4sERM52L Y9CzvFHLtTcBDg7WFhMedWo1fmYOub2tNLNMFACGr4hBW5LAKdFwdwkNd8+j+ZSKoyB3 3Yfw==
X-Forwarded-Encrypted: i=1; AL+hErGEZ2cbUAsWOcRbQAhVRiRGOnlsQy8QNRYnNGub2OZJbBOfn5Rs8IasnOjkq9oeUpssH1/V6Nw=@vger.kernel.org
X-Gm-Message-State: APuU4Z9x/nJSTXyg6kpeDNdwBv7MJ/m+sxEImG9UPv+J7VfYzPOHJePn L9yagKzDi0eWXNl2TnkWs7zo9th5FMfrE7DWKlD4s8+F85voFqJJccdw
X-Gm-Gg: AYBFou1WD4T6OwWblB2UpPm2t1mt01cBch1S8zi49YlH9i6Uo2k30ozrgAVqRomT9c2 r+BOQj0fPBIjSupGCQV7gtGmGcpzjM0Y4NiLdriQcwchpJ8hMKKDy9EZfgxMn/LxxTLkdi3S3zW SIgaFu2dttNaLyWQIZC/u+bT+Fpp4s9CZTYEFrCeQGSZ2deSgXVob7NFYvmK9+7lWeXjQF4Ovnf VAE/Tp2977ZNcDGjfJf2j5EtABv9CoEOr9/EzVaI4WfpmEviHJwskbiWcNMPD3plRxmcZS+y6+z hXumcJ3o5hfx/4lstxPLJOYrpTqu78cFD4X55mjFmEC2nzGOQH6fpkDYJD9/RV+d4Wnc6GGbpeW QEFnOC5GGao1nXWmDEE0HjEFMS5kFbwcdIdHmRgRCPGcNyoC9qyn/+b2VNhdMnT9BqkQ4MnKygC KRi5kux+52RcNCFtOVCVfdwCDjb+VarvbZmeWTgn2wIVo6IFWpqvZ2ksA4AjIT5cgZFD89Lzdlh ZgpvzlyR53ZVLUTTR8K7Ht6nAjWGW4UjHxTXi72HjrGI5tN2mmQM+RdG6YhUt+KpPYsJV/N40ue OWVtzp03Xkqx/lfyBR8n+ZotHhQ9DBjPKhDx3bDQESy1PH80mb1d7PcVU3jx7I9zRID3Mki1pOA NeErqSFv+xO0LSJ1lmU2W2zLSPi9eNHAKk0hs/DGyz2D0+WPrCKOOBfIdbtR6uM4=
X-Received: by 2002:a05:620a:460b:b0:93e:fa30:f1da with SMTP id af79cd13be357-949ba9e95f8mr157198485a.45.1795122802898; Thu, 19 Nov 2026 13:13:22 -0800 (PST)
X-Received: from gmail.com (15.60.86.34.bc.googleusercontent.com. [34.86.60.15]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb34a38bsm47654385a.13.2026.11.19.13.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 13:13:22 -0800 (PST)
X-Cc: Junyoung Jang <graypanda.inzag@gmail.com>, Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>, Gwanhyun Lee <gwanhyunlee@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
X-In-Reply-To: <20261119144241.360238-4-graypanda.inzag@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