🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19594

[PATCH net v2] vhost/net: Fix receive queue test in busy poll

#19594
From: raoxu
Date: Fri, 20 Nov 2026 03:38
72 lines
12872 bytes
From: Xu Rao <raoxu@uniontech.com>

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 <raoxu@uniontech.com>
---
Changes in v2:
  - Target net and add the introducing commit's Fixes tag.
  - Explain the raw packet socket backend and busy-poll decisions.
  - State the AI-assisted discovery method and document the diagnostic
    module test, its results and its helper-level coverage.
  - Document the targeted build tests.
  - Keep the code change unchanged from v1.

v1: https://lore.kernel.org/virtualization/20261110051642.249640-1-raoxu@uniontech.com/

AI assistance: OpenCode was used to inspect the history, prepare and run
the diagnostic module test, run build checks, and revise this message.
The code change is unchanged from v1. The discovery method was confirmed
by the author.

 drivers/vhost/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4570a4ffbab2..10ed2d55ff07 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -538,7 +538,7 @@ static int sock_has_rx_data(struct socket *sock)
 	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,

base-commit: 435cbdaf9b03687498dc16fe4af8d16a977e21d0
-- 
2.50.1
Technical Details
Message-ID: <1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367611-linux-kernel-netdev=dewy.ru

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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367611-linux-kernel-netdev=dewy.ru
From: raoxu@uniontech.com (raoxu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] vhost/net: Fix receive queue test in busy poll
Date: Fri, 20 Nov 2026 11:38:24 +0800
Organization: Usenet Network
Message-ID: <1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3052384"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:saMLqv7HqYapbX7bJM4sxY48GCo= sha256:WVdtw3xrxUFC+/IuaXcDpvwzpZD7AWIuv78RaYFYqdo=
	sha1:HxwbUvwvMgiAocwVHWEUT9Ggm2M= sha256:ilmvDNA7iV1NkmAXqVhDkQkNOercp4B85qU+2t0I7sY=
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 7794E115892; Fri, 20 Nov 2026 06:40:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=uniontech.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 TbslGcs43DYe;
	Fri, 20 Nov 2026 06:39:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367611-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=uniontech.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 28057115128; Fri, 20 Nov 2026 06:39:50 +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 B89BD14664E; Fri, 20 Nov 2026 03:39:46 +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=1795145982;
	b=TIBeLHdyM2AitMBkdLRqFhOfKLgeRlwtWNCcECKCpIf0d6PWvnffwptThm0A7jKnj/bi
	 ABnt2T3fvoi1a3SmF7ujxaD8dKX5Jj9vs1nocSYkn3ByYMWCO5BX4xTtpcfN1DSMeO/1P
	 ux5YiD6NqBT5dwhCHWnh49CG5ALsixXuDJtun8NhRWZ/X8a63uBh3dt+j3QJjHeInOT27
	 1xjqTm6EQGYR8FLG0Qv88b/GisuE7YEVd8S0nb/qH3inmqrJAjBjGqDZZPJ81K7MJMEE3
	 QEgGkN3geYWhn1qEwGVyRi0gNgcQgB+1iIHRCpqgNZ8Nrbq2QSMiiY7JbWtx9JiXowQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145982;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-QQ-mid:
	 X-QQ-Originating-IP:Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:
	 EX-QQ-RecipientCnt:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=6ID25TASgB9mY3j+/9ivqOm1LKio+2OprW84VL0Grno=;
	b=4bFuwcq3o2MPM5fWlGsh5hKOSBnlJjxcdVvYp8XQ8z/60y26DON65d56FErpqD0iCsyj
	 oURCGZ7HWRp4uZfptZwb7V70F4zOarB9pfpQ0d4OmXYHLmZUGU6kYywVX8cW1Ikg33bzB
	 sifOWHuXejIZH3XAtpjZm1pT5HJhuLzCW1zxEd/5eqmG0d7nAaXn9lJGuogdgmI6JHIKZ
	 XwJe29rcqXCvUJFW4V28OUkNbf3/dwqkZ5MrN5VmBwvjUyo2nY++ybD56vJhhi8NLQ7RP
	 8/TihXVPdxVi3Gfi99U6RSVl7zvDsk/msS03yZXEPmukKVEYYnjXbfugdvQj/GlNJ2g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=RaDWpzLq;
	dmarc=pass header.from=uniontech.com;
	spf=pass smtp.mailfrom=uniontech.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 3CCFF606A33C;
	Fri, 20 Nov 2026 03:39:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=RaDWpzLq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.204.34.130
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795145981;
	b=lObNNR/JT7NRMjGD5v7gCvM/6qU71OxjkeJzNDk/wXnjdcxWt1PaP3XjA37nntUGz0JP
	 A9ktQGnr2YBGmF2zBUt1HqXRYHu/LmbHDh4tWzd8qBB0xDXHiR/HE2lFRSh/+530u3JJo
	 9jAXLOjSiBiCHuw+jK2dZC8IzVyPt8TD0EgsdDVjyNW+GQlEuOT+IjFPDDY4ijQ2dIRev
	 vFwvX5PASSXQpwJL9Tv4rgrWRJHxbas9HtcYUQ9ClgLWFbdviaxmz8iLh4hRihLMtQghI
	 4P+XkTm3qA+HH+69RHuIgt0I+EZGRzoliqunylGYZDhfyWi1+aRF4yoTyppnHPghKcg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145981;
	h=DMARC-Filter:DKIM-Signature:X-QQ-mid:X-QQ-Originating-IP:Received:
	 X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=6ID25TASgB9mY3j+/9ivqOm1LKio+2OprW84VL0Grno=;
	b=F2ALR8kWF+f2XIYn8F3lJk8/GtFX8i3YBmcimttYcBddQT97WN7CwP4jXielDHFNgawP
	 G7yjceeqT4f2L7VQk3ZScpAQxquDGSPIGuhzfIZSpEzPcTAfe2Zc480XI7ot4wbzfXtRM
	 SPK2YApzRXeNH85enKTobynNbsS2hefxNXHBzXXDGgqBmrVAOl67wayA00DJUxzx2DpT/
	 INNJDQGJ3NwnHGCQ/tYt9WQRTrZjUKjoMsyL/vraaQeF2vpi3zulfJrMKYD5P8zp1c6St
	 ozfeGD55l+FC0+64wPP5dH2vxg6p4VdR75uhRcyPQrPlENbYcvztNpzLBrTEij7Z20g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=uniontech.com;
	spf=pass smtp.mailfrom=uniontech.com;
	dkim=pass header.d=uniontech.com header.i=@uniontech.com header.a=rsa-sha256 header.s=onoh2408 header.b=RaDWpzLq;
	arc=none smtp.remote-ip=54.204.34.130
X-Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72A38606A325;
	Fri, 20 Nov 2026 03:39:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72A38606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com;
	s=onoh2408; t=1795145912;
	bh=6ID25TASgB9mY3j+/9ivqOm1LKio+2OprW84VL0Grno=;
	h=From:To:Subject:Date:Message-ID:MIME-Version;
	b=RaDWpzLqCdYYGRlKySuGUQaSPqkaLKbto6xE75Z7DkWkxQkTgTfeRG0R94NcJFHIo
	 wZa943Zh1rATL+aq0YIJh0YyEYetiF/YBgVPubX62zIUIoXfixEo6Rm6SQSyUkWBcf
	 FklDE/31hdDk2EvwxWiT95VlBDo+MowuMgkvLIjc=
X-QQ-mid: zesmtpgz9t1795145907t2b7c356a
X-QQ-Originating-IP: 2Dvc6PhiaE8wquu067dn3SVToxhwDgWWzXwvNhwqyak=
X-Received: from PEN202512010004 ( [113.57.152.160])
	by bizesmtp.qq.com (ESMTP) with 
	id ; Fri, 20 Nov 2026 11:38:25 +0800 (CST)
X-QQ-SSF: 0000000000000000000000000000000
X-QQ-GoodBg: 1
X-BIZMAIL-ID: 5714097690566660774
X-EX-QQ-RecipientCnt: 10
X-Cc: jasowangio@gmail.com,
	eperezma@redhat.com,
	davem@davemloft.net,
	kvm@vger.kernel.org,
	virtualization@lists.linux.dev,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	raoxu@uniontech.com,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.50.1
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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