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=1796383475; b=jjTq62QA6id2sgMXjl2RyW+I3VukWsKL0L9GN1JeqtzRJ/5cKxX25IwSe+Ug1LjPQ9R5 UW+BTEqSvv6b3bXQNuO3VqTxeEx24IwhYlNNxVScKKOiEB0AZE1gEyk5n/tcaZktRNBiR P8VDAma9l/mDlzfwNNndU+C21v9NGCgcpjyBVtXyV1rr+GhMKWCWb6WMgezMmGVdYZUoz RT8Ejt2QHrpMgZDpAUoRzBxaKWQcvMMCaAAJLBkRts66tG6pvVD9/t5TVY2SVIYrphBE0 PhhRWssmEkV44qN/Iwo9bEgcXUgRxKwNIVlIVu52EQC1pSCFs5MDJNdri24blaI0Ehw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383475; 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=AXv/pI9zLNXh2L8YF1nJ3vO0liY9BTiIuoEGF14et60=; b=CJa+RRS/FIcmJu0FH7fx/xke82QEfiVwMAgD26CWgAnf/UgcGJOwiaDbSizc7WyKYHsW wJsbo+Yqv47z96NAu/ab+WJMeOp1bvYfotEnUzhUQV5P9Ag/N5SC8RGAqR5abeOsYnn1n rm44ZzPpBoINjacqY4AseWaGqajjyDaRjWVdWU/MK3B+Wj3WPZGktXwO1eqwEnBwILgh2 Qj4U3UQLkCorubz4aUy58EwQzcaNpbg32NII6KVrOjCDJg4GCsSytGTTDknr1MF3bqmJs SI5wl4wm2QefO0oCDCksFreBhvfJEki4y+eZCGspBYy7MoOFbgz+I6dQw5ykrvFQwkg== 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=c4pmoA1x; 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 08E55606A33D; Fri, 4 Dec 2026 11:24:35 +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=c4pmoA1x Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1600E1F000C2; Fri, 4 Dec 2026 11:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383474; bh=AXv/pI9zLNXh2L8YF1nJ3vO0liY9BTiIuoEGF14et60=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=c4pmoA1xsys8tiak+xIV1IoQZhsILr4wGtxEBzzHFIcTbNZw64i/T7HL+stze7t33 VdomazX2Kv93Bf3PRgGGxOPCwPwm3C8z/3DjleRLxfnbcR3jU39IO+8DoFPnmbK84z 5QQKHFf4bJkGAsMQ0w7pVMdoJ9j0nVJwXT+F3kxs= 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.12 240/555] tun: complete the zerocopy buffer of packets consumed by XDP Date: Fri, 4 Dec 2026 19:04:43 +0900 Message-ID: <20261204100618.339978126@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 e8b4d988cd330..016fc158e13af 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1844,8 +1844,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