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=1796382836; b=v/AQFz5YpBFbE4nOP54cfbujdv2Rb/M5Wi54ZwsPKd7Soed0rBu2kPpDdjiO1040bCoi S57Uxnm2VNhoP+fajeWS2RkigJs0J4/9PQsPXv0LYpM7oyPDYy04pzH8x3bJVW5OO0+Z5 H5zkJZxIYUZbohuFkdsbUp/AQFkDxOUmJxO36in+f/7Y8ukhbeHXcgGs618WPvOt50VNY 4y5mxr9RprisRww5HhCXZprPIOWncaOiCENNsps/15m23qeGKgC7TPYvLUf7jKrhiZ6Ns 3OztMe4be3A11vZXiiE1Wzr3OffnAzDBZB9rTAHI1+5kN0l7wX0LWlkalRIp/hlqEng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382836; 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=ByKcPG1GjABh5OHs4m57seXehoVlXtIGDtuqbi/IrnE=; b=sblLZFy5aTmLw0gkcjEG1UPNsMB8RrwjPqKnwiJHI6JPuGFx7Pmwhq1gaofEatQiMawl M+AVjzn0+lSUx9VO51CeOZdLPGvGdSJjuNILn/5hkef6LLztLNiyn4Cq28H8Fa9f+szHV A1gagr0ygi91gkvXXBLHn23QXN/ygTMb9ajx+CRfEEck26PzqF+MDHCmCcNFLbCCrV/Bs dB6rT6He9aUquQILnNoPpJC/B8S97l6qGCKh5UKGOj2iAaPLF7HfsYAOz999MqgOD7W/d kJjArhlv9iAXCzF/+tC6i7Ti7Njy0soNUuxDnaL5hY1Nz43DopJdWJ+rsFLKlrlZjEA== 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=o5ryTmg0; 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 08038606A322; Fri, 4 Dec 2026 11:13:56 +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=o5ryTmg0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BE51F00934; Fri, 4 Dec 2026 11:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382835; bh=ByKcPG1GjABh5OHs4m57seXehoVlXtIGDtuqbi/IrnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o5ryTmg0dPT7zuI2sechGP+MO5amDpwRsiiQvqsB1taVAfOOXuZJEy3WwLmXm8qMa vpcJpOx/qj9Udy/nzKwCwvjJK2jU+l6ytaKCZzijdZuupv1AH1QqU05VFRNzN3GHPl /UfDk/Pk6GQuG1HWFD9xmpFCeBxxG3b1le0nxCv0= 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.18 616/703] vhost/net: Fix receive queue test in busy poll Date: Fri, 4 Dec 2026 19:08:35 +0900 Message-ID: <20261204100644.166128465@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -531,7 +531,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,