🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12004

[PATCH net v2 0/3] vsock/virtio: bound what a peer can make the host queue

#12004
From: Oleg Drokin
Date: Fri, 06 Nov 2026 05:02
82 lines
12218 bytes
A virtio-vsock peer that does not consume what it is sent can make the
local side queue memory that no limit covers. On a host the peer is a
guest, and the memory is GFP_KERNEL, charged to no memory cgroup. Two
ways remain on net/main:

 - the send credit trusts the fwd_cnt the peer reports, so a peer that
   never reads but keeps acknowledging gets unlimited credit (patch 2);
 - credit updates are not bounded at all: a peer can solicit them with
   OP_CREDIT_REQUEST, or by sending small packets that a reader drains,
   while posting no rx buffers (patch 3). The same works against a
   guest whose device stops reading the tx virtqueue.

Patch 1 fixes the accounting of packets that vhost drops on rx errors;
patch 2 relies on bytes_unsent being right.

These were found by an LLM-assisted security review of vhost-vsock,
done while porting a project from Xen to KVM. Patches 2 and 3 were
reproduced (below); the error paths of patch 1 were not, as they need a
guest that posts malformed rx buffers. The same review found the
receive skb sizing problem that Daehyeon Ko independently fixed in
d5e912448cd9 ("vhost/vsock: size receive SKBs from declared payload"),
so that part is not in this series.

Nothing changes on the wire, except that fewer credit updates are sent.

Tested in an x86_64 qemu/KVM guest running the kernel under test
(net/main fafbc4051123). For the host side, the "guest" is a user-space
program driving /dev/vhost-vsock directly, talking to plain AF_VSOCK
host sockets. For the guest side, a nested guest running the same
kernel uses a vhost-user vsock device that stops reading its tx
virtqueue:

  case                                      net/main      this series
  lying fwd_cnt, no rx buffers, 2 s of      256 MiB       256 KiB
  non-blocking send() on one socket         queued        (one window)
  20000 OP_CREDIT_REQUEST, no rx buffers    +18.5 MiB     +0
  20000 1-byte packets, each read by host   +18.1 MiB     +24 KiB
  guest, tx virtqueue full, 200             200 credit    2
  OP_CREDIT_REQUEST on one connection       updates

vsock_test from tools/testing/vsock passes over loopback and between a
nested guest and its host. A bidirectional stress test (up to 512
connections streaming both ways, readers draining in small reads) runs
without stalls, and vsock_perf throughput stays within run-to-run noise.
A test that moves sockets between transports in connect() while their
packets are queued passes. With KASAN and lockdep enabled, these tests
show no reports.

The reproducers (a user-space program that drives /dev/vhost-vsock as
the guest, and the vhost-user device) are available on request.

Changes in v2:
 - patch 3: fold a new credit update into the one the socket already has
   queued, rewriting its header under the queue lock, instead of
   tracking it from virtio_vsock_sock with a refcount, an skb destructor
   and transmit hooks (review). vhost and the guest driver are no longer
   touched. A failed add to a full guest tx virtqueue no longer lets
   another update through (Sashiko).
 - patch 2: commit message only, the writer's wakeup is gated by
   sock_writeable().
 - all patches: say how the issues were found; patch 3 gives its test
   results.
 - rebased on net/main fafbc4051123.

v1: https://lore.kernel.org/netdev/20261105000141.3617241-1-green@linuxhacker.ru/

Oleg Drokin (3):
  vhost/vsock: release the accounting of packets dropped on rx errors
  vsock/virtio: bound the send credit by bytes not yet consumed by the
    transport
  vsock/virtio: fold credit updates into the one a socket has queued

 drivers/vhost/vsock.c                   | 23 +++++++--
 include/linux/virtio_vsock.h            | 66 ++++++++++++++++++++++++-
 include/net/af_vsock.h                  |  6 +++
 net/vmw_vsock/virtio_transport_common.c |  8 ++-
 net/vmw_vsock/vsock_loopback.c          |  2 +
 5 files changed, 98 insertions(+), 7 deletions(-)

-- 
2.56.0
Technical Details
Message-ID: <20261106050244.602625-1-green@linuxhacker.ru>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357750-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357750-linux-kernel-netdev=dewy.ru
From: green@linuxhacker.ru (Oleg Drokin)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 0/3] vsock/virtio: bound what a peer can make the host queue
Date: Fri,  6 Nov 2026 00:02:41 -0500
Organization: Usenet Network
Message-ID: <20261106050244.602625-1-green@linuxhacker.ru>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3797704"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:TvWdkDwi8DpMWf1tmpT3JozFllE= sha256:CIKx+YdR+6tab2/kZUXQXUgUXnJBDOXY9DFPsIKBzWQ=
	sha1:oFeI6bXyDTEai0UDipLrRNgpPUU= sha256:l3OeQS6DoDvWidV8lnwNarM7+SA8iqjVEyzsQmpumbI=
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 C94A4113161; Fri,  6 Nov 2026 08:03:46 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.151
X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31
	tests=[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]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=linuxhacker.ru
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 gneR6ZSc6zCo;
	Fri,  6 Nov 2026 08:03:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-357750-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linuxhacker.ru
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id D5C5B112E19; Fri,  6 Nov 2026 08:03:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id EDEE36034F4; Fri,  6 Nov 2026 05:03:18 +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=1793941391;
	b=mVX8E12kLwnv8NotqERU1Ox//Hkb8/QpKEKJCzbiYrHtA6iOXKVU1EZJK9BhVepwLdTM
	 NQLmrWXJHSgGIkEOfkxfhX0rsjhxIQvho62SkiIC9TgcPOj3r77iPhcJFEIJckJj2yxWv
	 hwSOjlWUPBAA9ZtPDypcgKB9u/BcZC/gFnutzMCYzJX7s7BzQjtKnZXtPeTPWt+PT7IIx
	 a6ZadyJ6MocwNgHU3U1jYS1svU9TbdYzx+ub7FXBDLEUt17c9Upi7mVh3tPai6tBcRgUH
	 oH2c/4ao1g8rXX7p/JS+Mw6DK0bb0n3QwTD3YuLIT/mfgS/bwgUNQwamL4sd+K+aVlg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793941391;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Filter:
	 DKIM-Signature: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;
	bh=P+cO6ALFn4ynv3OOBT/y6EBvmBlsF2ZJXUMXhExZ1l8=;
	b=ScdUGoORd5sHpxvEVTOX0yqOnpAX7x4TnHbYJDMRcCSsJIScnSXDzT3DpiB5ahTNr3Z/
	 dpUTBkY9cVnbCW6c+9f9JPt2ZDR8FRZ1cAo0MVcvWmUC+fVr1BTZdVmRvq6IJyza8KfJc
	 5dVWI4KPH7JXsnuPfwxfrlPL8dgXQ9Dn6H/C2pxV1TQyO9AW5DBCoBCaOmAv2OnSLfDNp
	 qj4qTUa/d0U9+VbzfwpOPIdPBCS4IogOvxUrkxwBnT50VwCvRWb0ENJzWmetWUTcYmg2U
	 32Kev7T+mpYZRkKurh3GTMjG7PVZ2iUvsris7K5O2AZiyvbg2rdMfsMY1SQLmakX7cw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linuxhacker.ru header.i=@linuxhacker.ru header.a=rsa-sha256 header.s=mail header.b=WnWQd8WH;
	dmarc=pass header.from=linuxhacker.ru;
	spf=pass smtp.mailfrom=linuxhacker.ru;
	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 0BC33606D827;
	Fri,  6 Nov 2026 05:03:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=linuxhacker.ru header.i=@linuxhacker.ru header.a=rsa-sha256 header.s=mail header.b=WnWQd8WH
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.69.87.85
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793941385;
	b=Lf8zqttIq4r8/X+L4WN+tVBYjBR3umRKfF3j4Dg3OaiF/vorj+skBLFO0ShDTZ8RIyUX
	 1uP2jNRW1vNDB1bMFFA/Qmx67Jroo1wdthwH/WOvv8BTmj9bDvhihLKTWOQngzIw0JHlx
	 meHs51FA7GzkUqrms92qTLDNXTGhdWC3tJsE6BvteIlnJnJJiU99M413EnjzXTEGSoWcV
	 oHxgicV6TiDNQVIfAzCOyMkMmCHZmjoRg65o7rZc7Ayn8mNBYETsJpk0ymz3J//otcPhw
	 HkklVYqGvdGUUKB5cFzXvGZSQ40/e7dFYpHJr9LHUg4/wJf2GgjcL6VBNW//RjJNMrA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793941385;
	h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=P+cO6ALFn4ynv3OOBT/y6EBvmBlsF2ZJXUMXhExZ1l8=;
	b=exSbPEwZIqFA++EqUx9TRZgWCnVZll6nrpIFlo+pJYmP1RC/5CZCCLr3fFV1/Z/3k1iy
	 D154Ki8AHTEqvxK0pgckDa00Z7FlJNQfzHf+bGFRAmBi/wEWP1OSjYU1+5VhK18V+cJVU
	 SVXzUCqzOb3YJsMgQUh6YcNNdhryWN5FNMucJC/8/pyn965a57iJDYkbhb2F/t27E2KV7
	 +aBdGfHenpV7PXEDs038qwVGb91AtLj2RGDCcCTee8MAuLrHWF7RAOwgMMaMI7V3YTBPn
	 r8OH1VGnNR/eiet85E4TFkERqj+VSvx+uRwc/D1Oj2Hxg681ZBF7LWjuYIArpNgssxA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linuxhacker.ru;
	spf=pass smtp.mailfrom=linuxhacker.ru;
	dkim=pass header.d=linuxhacker.ru header.i=@linuxhacker.ru header.a=rsa-sha256 header.s=mail header.b=WnWQd8WH;
	arc=none smtp.remote-ip=159.69.87.85
X-Received: from eagle.linuxhacker.ru (linuxhacker.ru [159.69.87.85])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B48606A326;
	Fri,  6 Nov 2026 05:03:04 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86B48606A326
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxhacker.ru
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxhacker.ru
X-Received: from intelbox1.virtnet (unknown [162.81.204.199])
	by eagle.linuxhacker.ru (Postfix) with ESMTPSA id 02380BEE42;
	Fri,  6 Nov 2026 05:03:00 +0000 (UTC)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 eagle.linuxhacker.ru 02380BEE42
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxhacker.ru;
	s=mail; t=1793941382;
	bh=czCB3kW021QBoOVBYCflGEJsyZ7jwVnnd8tARhzgMaM=;
	h=From:To:Cc:Subject:Date:From;
	b=WnWQd8WHVyV3q7/padmFXXeqhe0TYuLgw+UBvogn2VRgIpwGovAGkxTH0+tQzB8M1
	 cbYcZEUG654u4I7kYZIbzXJTgXGTq30RQqJrpPFEsXDAe5ank0VBXzdBw7Zvy/qgTa
	 La+brbagfcYYo+1pKNx1r1H8UPgfDLEGkNoUiJ9/ucV7jgW6TMkDYCG/myszOC7ctd
	 bh78AbkMZi+KxW2j+5dVgzWoH/tbzdKaePFgC+lmiiYXhiqD6HQPdM8sQ966Y8Jhz0
	 y7HTxELU84/lbmAjCSh7wzPVmmj6lX4xtKdwdHA29y6GYKnbuu0U6/v01B3tcOWRVm
	 Ho086BP5nssyQ==
X-Cc: jasowangio@gmail.com,
	eperezma@redhat.com,
	xuanzhuo@linux.alibaba.com,
	bobbyeshleman@meta.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	netdev@vger.kernel.org,
	virtualization@lists.linux.dev,
	kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.56.0
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.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list