From: sashiko-bot@kernel.org
To: "Honglei Huang" <honghuan@amd.com>
Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v11 4/4] drm/virtio: wire blob ioctl creation to userptr objects
Date: Wed, 02 Dec 2026 10:46:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-245513@kernel.org> (raw)
In-Reply-To: <20261202101658.1209083-5-honghuan@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/virtio: out-of-bounds user page pinning in verify_blob() on
size ALIGN()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] drm/virtio: silent blob size truncation in verify_blob()
[1]
--
commit 47f959d0cfefd215bffd18078894e965cea40441
Author: Honglei Huang <honghuan@amd.com>
drm/virtio: wire blob ioctl creation to userptr objects
This commit wires the blob resource creation ioctl to userptr objects, adds
support for the VIRTIO_GPU_F_BLOB_READONLY feature, and adjusts blob size and
userptr alignment handling.
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 81e70a12b3569..454d0e9a7d59d 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
[ ... ]
> @@ -538,10 +565,16 @@ static int verify_blob(struct virtio_gpu_device *vgdev,
> params->blob = true;
> params->blob_flags = rc_blob->blob_flags;
> params->blob_hints = rc_blob->blob_hints;
> + params->userptr = rc_blob->userptr;
[Severity: Critical]
This problem wasn't introduced by this patch, but does assigning the 64-bit
rc_blob->size to params->size just above this [1] silently truncate
blob sizes over 4 GB on 32-bit architectures?
params->size is an unsigned long, so on 32-bit systems the upper 32 bits of
rc_blob->size are discarded before alignment checks, allocation, and host
command submission, allocating a smaller buffer than userspace requested.
> - if (vgdev->has_blob_alignment &&
> - !IS_ALIGNED(params->size, vgdev->blob_alignment))
> - return -EINVAL;
> + if (vgdev->has_blob_alignment) {
> + params->size = ALIGN(params->size,
> + max_t(uint32_t, vgdev->blob_alignment,
> + PAGE_SIZE));
> +
> + if (!IS_ALIGNED(params->userptr, vgdev->blob_alignment))
> + return -EINVAL;
> + }
>
> return 0;
> }
[Severity: High]
When params->userptr is non-zero and vgdev->blob_alignment is larger than
PAGE_SIZE, can rounding params->size up to vgdev->blob_alignment cause
virtio_gpu_userptr_create() to pin guest pages past the end of the
user-supplied buffer?
Unlike shmem or VRAM blobs that allocate new backing storage of params->size,
virtio_gpu_userptr_init() sets userptr->npages = params->size >> PAGE_SHIFT
and virtio_gpu_userptr_get_pages() pins that many pages from current->mm
starting at userptr->start. If userspace passes a userptr buffer whose size
is not a multiple of vgdev->blob_alignment, the extra pages past
rc_blob->userptr + rc_blob->size either fail in pin_user_pages_fast() with
-EFAULT or pin and export unrelated pages from an adjacent VMA to the host
device.
[1] https://sashiko.dev/#/bug/linux-20577b57-1c85-44eb-8080-3e8c4e2bce2a
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202101658.1209083-1-honghuan@amd.com?part=4
prev parent reply other threads:[~2026-12-02 10:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 10:16 [PATCH v11 0/4] drm/virtio: userptr blobs for native-context compute Honglei Huang
2026-12-02 10:16 ` [PATCH v11 1/4] drm/virtio: add VIRTIO_GPU_CAPSET_ROCM capability Honglei Huang
2026-12-02 10:16 ` [PATCH v11 2/4] drm/virtio: add userptr blob resource to the UAPI Honglei Huang
2026-12-02 10:16 ` [PATCH v11 3/4] drm/virtio: implement userptr resource support Honglei Huang
2026-12-02 10:29 ` sashiko-bot
2026-12-02 10:16 ` [PATCH v11 4/4] drm/virtio: wire blob ioctl creation to userptr objects Honglei Huang
2026-12-02 10:46 ` sashiko-bot [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=sashiko-outbox-245513@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eperezma@redhat.com \
--cc=honghuan@amd.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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