🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5903

[PATCH] vhost/vringh: reject zero-length indirect descriptor tables

#5903
From: Fang Xieyan
Date: Wed, 21 Oct 2026 07:02
35 lines
9522 bytes
move_to_indirect() accepts an indirect descriptor with a zero length,
setting desc_max to 0. __vringh_iov() then reads descs[0] before
checking the descriptor bounds, resulting in an out-of-bounds read.

Reject a zero-length indirect table in move_to_indirect() so the
caller returns -EINVAL before dereferencing the table. Also use the
converted length in the warning to report invalid lengths correctly
when the vring byte order differs from the CPU byte order.

Fixes: f87d0fbb5798 ("vringh: host-side implementation of virtio rings.")
Cc: stable@vger.kernel.org
Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
---
 drivers/vhost/vringh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 9066f9f12ba1..ce4f5a02c8d2 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -197,8 +197,8 @@ static int move_to_indirect(const struct vringh *vrh,
 	}
 
 	len = vringh32_to_cpu(vrh, desc->len);
-	if (unlikely(len % sizeof(struct vring_desc))) {
-		vringh_bad("Strange indirect len %u", desc->len);
+	if (unlikely(!len || len % sizeof(struct vring_desc))) {
+		vringh_bad("Strange indirect len %u", len);
 		return -EINVAL;
 	}
 
-- 
2.50.1
Technical Details
Message-ID: <20261021070242.75009-1-fangxy@xiaopeng.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349852-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!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349852-linux-kernel-netdev=dewy.ru
From: fangxy@xiaopeng.com (Fang Xieyan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] vhost/vringh: reject zero-length indirect descriptor tables
Date: Wed, 21 Oct 2026 15:02:42 +0800
Organization: Usenet Network
Message-ID: <20261021070242.75009-1-fangxy@xiaopeng.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4052500"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:UxEqZQcqJosfHlCbrqhiDeky/5I= sha256:kUKhonUsRvuraCBebejCC0Ua9g+e+qtXW5OV9beo9uQ=
	sha1:vGXFEOEjCWoWRIeCPJ/CvptN1/M= sha256:reQn8VTEm6MyILy3y3v0xJv7pErk+3ilKLtWeFtz+8A=
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 E9E24110F4D; Wed, 21 Oct 2026 10:04:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, UNPARSEABLE_RELAY=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=xiaopeng.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 mc8jDzxgIi-N;
	Wed, 21 Oct 2026 10:04:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349852-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 7754A110F4B; Wed, 21 Oct 2026 10:04:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C5E19435D8; Wed, 21 Oct 2026 07:03:03 +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=1792566183;
	b=khBkf1KTsGbiHh57NJxsRspCRvMN6WGUMZc9KMXTjHdvPKlidjuD5PmLhTVwX+HuekBb
	 u/vzi6ZKwhmIovaxK/3srUBsFLgYAWl3dLe1WQWbJZmSUW6+nDpAq2cyZkp5UKVjkNX3M
	 mz5IKbjgj0GlQwRs6EhKTWJrKkty7mr82MKFoScaY1/1IzWEAHtrIPEBjSkjxgciMu4ep
	 L5mYv0sXicokQtidzy2uPgWr2PVVN0h0sv2hgBYirf9oXBRITvkT4VGlsBXvy1Kssa87j
	 OB5p/qs/+J/8VZ0Xyrv0BRThNRqRNb1lMgcmyqjBFmozKYkhioa2YXSj+z1A2258slw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792566183;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-Alimail-AntiSpam:Received: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=9ejJRb6pdg5woczfJr39UioN6agm7SyfQ7LOX7To5E0=;
	b=LAscOoR9gmXYK1KEQ6g/1HC1SfMBGcl+NNhLyLwhjcEAS6dGFvpdXnKpVda0y0LE9Sy/
	 JX7x4qk73bWWNgL98R8uiSwEGpUl2Z4Tq0b3hZbFAd/7K1SQUhxMd19Ql5BWtEoe6IU+e
	 ptmxdxVrzs7GLyvFtm647LGFEG3gOfAfGEGqpUDFM9SeDla9EKFVpfkWrfN/Q5vv2v9Qm
	 7AyPqY9qJ7RwyS5nLp9jiBG+tYP/aI+78vjeRN64lFhArf96UYvxsNgagacbIJ0bal5bJ
	 CmoM9GOfoqu7u0Z7Y4HK1yxlvYfE4dcAza6YPDP2Dq5x3j33rSSlR1IMotacrvRm99Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=YwrEjJIt;
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.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 48F20606A326;
	Wed, 21 Oct 2026 07:03:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=YwrEjJIt
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.219
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792566172;
	b=clheuX+dwFJ8J/aMTGIlpwnaG0S4JiH+ZOlEoK9DcRYSUp3pF/qfax7owLU1sV227eUU
	 nm9sJgLYJDYv3VTxF43C9lTKIyUQHGSpI1C1AhwM4hy+Ck8S0krZ+GthVW16Io0DXsX1e
	 zzlYqpeNB/1TJq/hscTXWnflnE8lqoKOvd769HZiHBel/lf3oHFk6rqDSyUvlkt51MZ9E
	 JoYcDqKoxzO2clqzk/+7yJU8pciXQe1livjEZAhV4KzCDhkg+go1iBsX/31/gvdiZcGDE
	 98VIYp1Jpy2LmD2Q4UouRb+ni+XwFicsSsQS0KT4OLRwliFzx4HYpEEsxm0Uio+Y4AQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792566172;
	h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=9ejJRb6pdg5woczfJr39UioN6agm7SyfQ7LOX7To5E0=;
	b=xNqS6mFaNLgzUxDlPLlxoC5TKeQD5cValzKQd9g74NeGqF4VeU8zSiGiUm79XdbZx1j8
	 7wulky19KINCUbNum7xQGeA8Bs+kK9NxkhPM+3DsR0U94EmdXbJwUzZnrLnxihnaQBX2U
	 lhcMrzvLG18wC2abvV250mhb4b7j3vkL6PGasFTatrf7eAkwD4RMS+izSZM7Q+XnWjXEn
	 sgDKLZtpAqyQ9pU/FHAU0e4MpQL3IVPsAIjeVIrJ8CBDnPL8k6UOMp0H4YonXYqmnqwIm
	 firKnz40LehrKaXgpkGatKJYRJT6kR591W+uIaln+/nbjqphORgLa9pwBdAhwFBK0kg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=xiaopeng.com;
	spf=pass smtp.mailfrom=xiaopeng.com;
	dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=YwrEjJIt;
	arc=none smtp.remote-ip=115.124.28.219
X-Received: from out28-219.mail.aliyun.com (out28-219.mail.aliyun.com [115.124.28.219])
	(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 6AD70606A31E;
	Wed, 21 Oct 2026 07:02:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6AD70606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=xiaopeng.com; s=default;
	t=1792566164; h=From:To:Subject:Date:Message-ID:MIME-Version;
	bh=9ejJRb6pdg5woczfJr39UioN6agm7SyfQ7LOX7To5E0=;
	b=YwrEjJIt4Qo2FdRuNOIoq0rWZzvczRVxu1ZDl9XYrMwmtZbAsx906yO1AsMaqHJ95+djlFgp/fasCxqckiJRM5wCxhabrr5zhRwRDkuLVG9P0hBLg3t+q45DdRCqsv3kRJYSwOhhzEettNz+mL2VQHSflKpnysf2MOD8xpkPArI=
X-Alimail-AntiSpam: AC=CONTINUE;BC=0.04958579|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_alarm|0.00520256-0.00060955-0.994188;FP=10361852787305131134|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033025068124;MF=fangxy@xiaopeng.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.jmQmQl9_1792566162;
X-Received: from localhost.localdomain(mailfrom:fangxy@xiaopeng.com fp:SMTPD_---.jmQmQl9_1792566162 cluster:ay29)
          by smtp.aliyun-inc.com;
          Wed, 21 Oct 2026 15:02:44 +0800
X-Cc: Stefano Garzarella <sgarzare@redhat.com>,
	virtualization@lists.linux.dev,
	kvm@vger.kernel.org,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	Guanglei Zhu <zhugl3@xiaopeng.com>
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.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list