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=1796384172; b=QcUsBtT9dgpU/5YcxAwiHoB0AFn/rutVW8h7OTnD6lrS5MJoCeiEfFRHglyosnZSH3oe Fem+6m9TxS/WGW8Q3wQbqpaKMovCVURo8/zQCyFv3xkelHhEv5tMMc0bHhqUTmAwpbVnJ xItpZw/QOcfFtVN+WcSOhSaD3JuN9teNX7RuQh2kINN7iaPprEFuY29QVbVHZL/Q3E69M wMrOQMvSM1yT8+f685Y+XprC9b4LsheJIWEAVKXgDqXoqw+BmcJQQ4XTbG5TkMg0X3ddy wjBb3mlpTk9OREqzpnR6FyD/Y+a2kfCeGChbohjWef6/7pS6UVCXTLUCvlBXzDG0YyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384172; 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=I74+VANWpMDf4qpwZDgUtajSO5fwr+RWWqFt7l4RMRE=; b=1nfohPOYc9QyEpGV55Fp2VhfuGajavuGQ5dsitZfzChv6piLJ7NGiXkTBhAEj+++GWG3 hTDz9Kh0HK8rjbJ24N/eZphu+2Pa47sk+HDrj6jo1/cV+w2r1Twr/9WFqVeTvqB+QAj9Q qItKy7fCPPrIeSdv8tulhuEvB4FtGVx5UGiPluG/yvMKui0Kkt+spljMdr1AMIKLsEqZG CcNygkfgKSCIRMG8m45Hyu0r2Zm223VMdlBm8d2+mPY8mxRZMmLl6u6wh50PPSskEo1K8 v2qbfvIEF8ss7KVelG0FcO0xSXhYf4YD324/qDhTYVGrHUulzGWyvgQDomPbOWksZZg== 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=W6gqe5Y+; 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 94B87606A322; Fri, 4 Dec 2026 11:36:12 +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=W6gqe5Y+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id B73CF1F00935; Fri, 4 Dec 2026 11:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384172; bh=I74+VANWpMDf4qpwZDgUtajSO5fwr+RWWqFt7l4RMRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W6gqe5Y+q/32SHUEKu5gyCtJijfA3qgJ8iI/djnUEGT5erSkrrwKu4t5/yv/FRb+0 FNfaTO35crQCek+fh9yFm2zOl7lkSy2Y4kBGUIWHdbhrS8GZ1PRkmfN5ujA8j/kvqj UA1YjhntPZZv6Otu2ESRyPtOygqO+W94GSvrmf6Y= 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 6.12 527/555] vhost/net: Fix receive queue test in busy poll Date: Fri, 4 Dec 2026 19:09:30 +0900 Message-ID: <20261204100628.813417094@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: 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 6.12-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 @@ -518,7 +518,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,