Linux virtualization list
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Seojin An <love09010224@uos.ac.kr>
Cc: "Jason Wang" <jasowangio@gmail.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	virtualization@lists.linux.dev, security@kernel.org
Subject: Re: [PATCH] virtio_ring: reject unrepresentable split indirect tables
Date: Thu, 26 Nov 2026 03:22:41 -0500	[thread overview]
Message-ID: <20261126031810-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20261126080209.2898344-1-love09010224@uos.ac.kr>

On Thu, Nov 26, 2026 at 05:02:09PM +0900, Seojin An wrote:
> Split descriptors store the next index as u16. alloc_indirect_split() can
> allocate a larger table, but virtqueue_add_split() feeds the truncated next
> value back into its construction index. With more than 65,536 SG entries,
> the index wraps and later entries replace descriptors at the start of the
> table. The device then consumes a chain different from the caller's SG
> sequence.
> 
> Reject split indirect tables whose entry count exceeds the representable
> index range. Keep the existing compatibility policy that permits
> representable indirect chains longer than Queue Size, and leave packed
> indirect descriptors unchanged.
> 
> A virtio-gpu render client can reach this condition with a vmalloc-backed
> EXECBUFFER. In a no-vIOMMU QEMU/virgl guest, the resulting command
> substitution provided guest physical read/write and initial-namespace
> uid/euid 0. The virtio-gpu producer needs its own Queue-Size check because
> its current queue error path warns about an add failure but advances
> pending state and reports success.
> 
> AI tools assisted the source audit, reproducer construction and patch
> drafting.
> 
> Fixes: 9fa29b9df32b ("virtio: indirect ring entries (VIRTIO_RING_F_INDIRECT_DESC)")
> Reported-by: Hyeonjun Hong <hyeonjunhong330@gmail.com>
> Reported-by: GEONWOO HAN <gunwoo9643@uos.ac.kr>
> Cc: stable@vger.kernel.org
> Signed-off-by: Seojin An <love09010224@uos.ac.kr>


Sorry I don't get what all this is doing and how does it have to do
anything with security?  Drivers mustn't submit requests with more s/gs
than the vq size. Fix it there pls.

> ---
>  drivers/virtio/virtio_ring.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index f683a2d6a2002..ad9e52584fb52 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -686,9 +686,19 @@ static inline int virtqueue_add_split(struct vring_virtqueue *vq,
>  
>  	head = vq->free_head;
>  
> -	if (virtqueue_use_indirect(vq, total_sg))
> +	if (virtqueue_use_indirect(vq, total_sg)) {
> +		/*
> +		 * The core historically permits an indirect chain to exceed the
> +		 * queue size.  Preserve that policy, but do not let its 16-bit
> +		 * split descriptor links wrap within the allocated table.
> +		 */
> +		if (unlikely(total_sg > (1U << 16))) {
> +			END_USE(vq);
> +			return -E2BIG;
> +		}
> +
>  		desc = alloc_indirect_split(vq, total_sg, gfp);
> -	else {
> +	} else {
>  		desc = NULL;
>  		WARN_ON_ONCE(total_sg > vq->split.vring.num && !vq->indirect);
>  	}
> 
> base-commit: 40212b29a6f718d4e7fb3275cede181cb8e137cf
> -- 
> 2.43.0

      parent reply	other threads:[~2026-11-26  8:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:02 [PATCH] virtio_ring: reject unrepresentable split indirect tables Seojin An
2026-11-26  8:10 ` sashiko-bot
2026-11-26  8:14 ` Eugenio Perez Martin
2026-11-26  8:24   ` Michael S. Tsirkin
2026-11-26  8:41     ` Eugenio Perez Martin
2026-11-26 11:24       ` Seojin An
2026-11-26 11:36         ` Michael S. Tsirkin
2026-11-26 11:28       ` Michael S. Tsirkin
2026-11-26  8:22 ` Michael S. Tsirkin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126031810-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jasowangio@gmail.com \
    --cc=love09010224@uos.ac.kr \
    --cc=security@kernel.org \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox