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 <[email protected]>
> Reported-by: GEONWOO HAN <[email protected]>
> Cc: [email protected]
> Signed-off-by: Seojin An <[email protected]>


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

Reply via email to