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=1796381402; b=5I1o53cZCqzn0+lJ8JZLBi8rkgpP7OcueNHhm4mCwAFU1mZQVmwN8t3jNnh+fB2xacYf l7C5p1NQgo8PeLVqEKSljW69o3IyoMDG7bnVImOpc7VsUI7Hk6usiJdQanab7Qu6DaKsk lAXAOKrY68pdB6VC0B/FyhSp3aL0rh+wA4ZHRsESGANShIm9hHLIvE8HlDrr9+0t2Rq/g yQoMkfoMppFNIdnhQPrsiamcE6Uiif/DUmdMivyCPmzs9nbYO8cLB2v3oAJxR2cfjlF9y 80bgoI4QirLZ9xZf9Oisa2YtekLnxptn0OBYwe9OS2xVnY3xm/r+5A36eR/a7PpK8SQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381402; 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-Type:Content-Transfer-Encoding; bh=KjwniODaQSQKKlvjnjMIah/NeoweQrbvL1BXiqXPvyA=; b=NDlYUCltUgLI4UW5AZapU4bJWGm/d7PCcw1++E1MVpWBG7Ak+UMwBZLq1xyzcPBrGhrJ XPs5lT+AjPjscfA2WO3F3cpovnU0OIFbFJS1p/V6cirhSQDc3s4ZV3aTwuXJVfIOnobYy hnKSGVSl2ub5VE2i5dkQT4HKrNg+my/xeuskgLE6Ewg8hvDbiLwJOKOt/ydyAT6jWZPQu eF04w46MgnWEF0Sz/bJrEgd6pat3swD4gmIhQdahMu4THrQmg42U1AnLagBAQfh7Yu77W cgPrbLPNqCf2Zb3MQFoPtGZb9t6D0O9gfoBsGNgEqwdK4jGJ72E+DGprdRyDHL9yrwA== 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=lI9apYa0; 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 E0414606A322; Fri, 4 Dec 2026 10:50:01 +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=lI9apYa0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 772331F000C2; Fri, 4 Dec 2026 10:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381401; bh=KjwniODaQSQKKlvjnjMIah/NeoweQrbvL1BXiqXPvyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lI9apYa0WRZAX2G9O874VgG7hCsLDjl0XCAqBCQAtf1wyG7flc8QMoWCIa7N61eqN Fgu3VyZN8xtXzLdwwFsH01wotKnrjRQDrkMjs5/3bRx0cGl/bYk3VpZJUKUYa0KoFn YMi6lkL89FspLlYhRAoMpeDUMOkd95PUjQcfVEUw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xu Rao , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Willem de Bruijn Subject: [PATCH 7.3 687/742] vhost/net: Fix receive queue test in busy poll Date: Fri, 4 Dec 2026 19:09:11 +0900 Message-ID: <20261204100653.303938881@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: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xu Rao commit cdf84b850584574fc81bd80990d3bf1cf81b6a00 upstream. sock_has_rx_data() returns a positive value when receive data is available. For sockets without a peek_len() callback, however, its fallback returns skb_queue_empty(), which has the opposite meaning. An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a vhost-net backend, and its socket operations do not provide peek_len(). With busy polling enabled for this backend, an empty receive queue is treated as ready and a nonempty queue as not ready. This can make vhost_net_busy_poll() stop polling prematurely or fail to stop for queued receive data, and invert its receive-side scheduling decision. TUN and TAP backends provide peek_len() and are unaffected. Negate skb_queue_empty() so the fallback matches the callback and the readiness checks in vhost_net_busy_poll(). The issue was found during AI-assisted code review. The helper's incorrect result was confirmed on x86_64 running 6.6.0-amd64-desktop using a temporary diagnostic module containing the original and fixed helpers. An AF_PACKET SOCK_RAW socket, without PACKET_RX_RING, was bound to loopback in a private network namespace. Across three cycles of sending and receiving a 60-byte frame, the original helper returned 1 for an empty queue and 0 for a queued frame. The fixed helper returned 0 and 1 respectively, matching socket readability in all nine checks. This tests helper copies on real sockets, not the running vhost-net busy-poll path; the vhost-net module was not replaced. The patched drivers/vhost/net.o was also build-tested on the net tree with x86_64 GCC 12.3 and W=1 under allmodconfig and allyesconfig. No end-to-end vhost tests or kernel selftests were run. Fixes: 1576d9860599 ("tun: switch to use skb array for tx") Cc: stable@vger.kernel.org Signed-off-by: Xu Rao Acked-by: Eugenio Pérez Link: https://patch.msgid.link/1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com Signed-off-by: Willem de Bruijn Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -538,7 +538,7 @@ static int sock_has_rx_data(struct socke if (sock->ops->peek_len) return sock->ops->peek_len(sock); - return skb_queue_empty(&sock->sk->sk_receive_queue); + return !skb_queue_empty(&sock->sk->sk_receive_queue); } static void vhost_net_busy_poll_try_queue(struct vhost_net *net,