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=1796380255; b=AID0grmgBVPqOLuE6dMYv1dEnDCn9HjDGOD9EMH5o/xi/JKNxw2ShKkDeOKNBhuskuSh goJWka9z+4N8Dcn9grvd/NV+oEhBaBtlW8qSRoEXFbwuXczqSIrW7TQSLwktBnbXf/LjS H69WOmWWDrlmBKAMgyrCQP8jCuH22xTgY17LOp2HlHagVLfIceMnEcvpMgjjX6hUs30rf sJ5v/WQV3j2IFM0dDzZq5Pp63I9emHyCMqOenNzJLObUXQ60R9OEkk+fQSbtIl5VSaUwk 9753Oe+rpnBXGCQo/ctPY94/b0IlSoZLQbyKbE+YodjPYyKsIQM0KEGTXRMOgeH7W7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380255; 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=+ewHQT86iRR/v5yvRBZBb9ODCje6iXVDJQ+fMlF80b4=; b=BC3fUZ435HextGMjediQkcw5DVbRh+tAc0FMJbw+MyNOZ+F1otBmH2pcmluGzSoGp+Hg czqXtTZW6eXSDZ/E8neWUhb5mrsjKGO6PF3VcnKPzI6hloVJBoB3u5dhCOLWLyRoUmjpg qXcCktnOSt+l+27BLp2lN7HjN7znp0e3+4mlL6SQb40um7O6BGXx0IBthWnuOYD3SNJk8 c0tvOJhYTkcUSXwRhQcqibQ3mS1KTKz6VO57ZVn/BKNMxdRZXML+S78FoA5jNt9fL4xDS 0qZr5tPz6N9JRvIB8ntEyXVTUOinpKF+LlCAH4OxM3YlIevbxJ92Gqt4i1/5gsrjCjw== 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=qYSffCW0; 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 3C92F606A322; Fri, 4 Dec 2026 10:30:55 +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=qYSffCW0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3F431F000C2; Fri, 4 Dec 2026 10:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380255; bh=+ewHQT86iRR/v5yvRBZBb9ODCje6iXVDJQ+fMlF80b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qYSffCW06iW+XGYoMQY6Ok/hZVuHM1S7BisL2jkKKtHRayVsMM8NO30h/hWA3vMZJ XMxlajEyJPSbErd8vQ+/mfNfrdVAjYV0WqVVQUkH5dV9krUCYoeI6BH+TuAuvwiPjI eXGDwYb8zrqTKQLRdnP0D4GcHKaxgxOPwTuPrVYs= 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 7.3 195/742] tun: complete the zerocopy buffer of packets consumed by XDP Date: Fri, 4 Dec 2026 19:00:59 +0900 Message-ID: <20261204100640.262548548@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 092adb497dc76..970788939ac54 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1871,8 +1871,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