From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796382024; b=qUseWV7yQwbWtKvvy1Wr4922k3Cd8380Qu2C/hz93jYJczLm51ADhQfG0sa/5Gq0vHSo GanbGD9A22Z3OCtrcLARtQNPdQu4QrD95WSCo1Yk2up/WN5TPrE0PzQFa7sU5G6RoTHiW 4pDfeB40avC4DdtMp8BcK6dk8bNpfa0xW1V/UUx8BXjAPceQAq36iekgk+iXjlYhLtARd Txywjz6K2fcVuhg2fpEI8LMYjn/Lx8s8bGBFLtQQQREYUyGg1QAZNcVT0gBprz3imj5/c xzyi32JZjhCIntRm8kYESR8bEmPKc9/tS8/3Xl1Flb/4JNy+ITtNPIbWPrc36eXNesg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382024; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=u9+oIyOoy9Uid4XWHknpU3DVfw3NmayY4x6WDE/YvWU=; b=wlURpqCKbFqQwnkg4FfLf4Y4xPV6R/VjxIGKsLEogi5315dWa6VX8zg0u4TjtoF0ahIs dCb1+AQHCp6WpmBCDnfS3GtaO5mFte5EpRD2ATWOcbBynSv/VUMF+LhDzAxKx8gt9HbgV iP1Qkt5f8sMHV/ICBuNqgpwBSvOmwvD4ovkYH3Kp81QVdDtMKSxHRU8WnYU0GrA5LjFoU TTrPB4tYnRLMpHcuj4u/cxx5RCdsGNafDwuJyus/J9u0XHZ3oUppVzg8fvG6R4ceqO6nW 6FgdtRML7ARPNT6Xt8mscmffuN+1/KsQg4KcPvktmlfunRXg7wFBQxuZFPqBvLtwmDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=g+CDr3Qc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B1D1606A332; Fri, 4 Dec 2026 11:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=g+CDr3Qc Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9EE41F000C2; Fri, 4 Dec 2026 11:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382024; bh=u9+oIyOoy9Uid4XWHknpU3DVfw3NmayY4x6WDE/YvWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g+CDr3QcJ888h2k6U8c5Y9d/FLH85h22hXw9f54Uxocl9ljLPOos86nrHTs0CWVdu x7H/MIfCKMsLn1bTdWK2JcMCdmrf/VPEMaWAhJEDLF/ezZ9jezop6xVy15HjpqNvv3 LJai4nWK9NysIFKd82Yd8ALZQW5eglaK0tsG06lo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Antonio Quartulli , Paolo Abeni , Sasha Levin Subject: [PATCH 6.18 234/703] tun: complete the zerocopy buffer of packets consumed by XDP Date: Fri, 4 Dec 2026 19:02:13 +0900 Message-ID: <20261204100634.041687429@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antonio Quartulli [ Upstream commit 3896ae4adf5ffc11ffd0f7f42c3923e8dc195e75 ] When vhost-net passes a zerocopy buffer that tun_get_user() does not use, because the packet spans too many pages, the packet is copied and the buffer completed. If the copy goes through build_skb() and native XDP consumes the packet (DROP, TX or REDIRECT), tun_get_user() returns without completing it: vhost-net never gets the descriptor back, and closing the vhost-net device then blocks forever. Complete it in that case too, as copied. Reproducer: vhost-net with experimental_zcopytx=1 on a tap device with a native XDP_DROP program; send one 806-byte packet as 40 descriptors, each in its own page. The descriptor is never returned and close() of the vhost-net fd does not return. With the patch it is returned. Tested in an x86-64 VM with the reproducer and the tun kselftest. Found by the Sashiko AI review bot, as a pre-existing issue while reviewing an unrelated tun patch, and confirmed with the reproducer. Link: https://sashiko.dev/#/bug/linux-f9997fb6-303f-41d6-93e2-60c392b1856f Fixes: 761876c857cb ("tap: XDP support") Signed-off-by: Antonio Quartulli Link: https://patch.msgid.link/20261113232843.2338734-1-antonio@mandelbit.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/tun.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index b244ae7f4d5eb..d0e7252d8d363 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1790,8 +1790,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, err = PTR_ERR_OR_ZERO(skb); if (err) goto drop; - if (!skb) + if (!skb) { + /* consumed by XDP, after copying */ + if (msg_control) { + struct ubuf_info *uarg = msg_control; + + uarg->ops->complete(NULL, uarg, false); + } return total_len; + } } else { if (!zerocopy) { copylen = len; -- 2.53.0