From: sashiko-bot@kernel.org
To: Syh-Xiong <1850029304@qq.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] virtio: Handle vbuf allocation failure in panic path
Date: Wed, 02 Dec 2026 13:53:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-245908@kernel.org> (raw)
In-Reply-To: <tencent_108E6BD0C2683FCD678A1B68C99A5CFFF806@qq.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/virtio: NULL dereference of virtio_gpu_panic_get_vbuf()
return in callers
- [Low] drm/virtio: missing Fixes: trailer for commit 6f3d9d0dd335
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] drm/virtio: slab allocation deadlock in
virtio_gpu_panic_get_vbuf() [1]
--
commit 3cd455d3f4907312dc90888e92ffe07456cc5f36
Author: Syh-Xiong <1850029304@qq.com>
> virtio: Handle vbuf allocation failure in panic path
>
> virtio_gpu_panic_get_vbuf() does not check the return value of
> kmem_cache_zalloc(),so a failed allocation is followed by a
> NULL pointer dereference.
>
> Signed-off-by: Syh-Xiong <1850029304@qq.com>
[Severity: Low]
Should this bug fix include a Fixes: tag for the commit that added
virtio_gpu_panic_get_vbuf()?
Fixes: 6f3d9d0dd335 ("drm/virtio: Add drm_panic support")
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index d99fb9e326e81..0d7ae44471522 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -94,6 +94,8 @@ virtio_gpu_panic_get_vbuf(struct virtio_gpu_device *vgdev, int size)
> struct virtio_gpu_vbuffer *vbuf;
>
> vbuf = kmem_cache_zalloc(vgdev->vbufs, GFP_ATOMIC);
[Severity: High]
This problem wasn't introduced by this patch, but calling
kmem_cache_zalloc() from the drm_panic handler can deadlock [1] if
the kernel panics while a slab allocator spinlock is already held, hanging
the system before the panic screen or kdump can run.
> + if (!vbuf)
> + return NULL;
[Severity: Medium]
Does returning NULL here still result in an immediate NULL pointer
dereference in the callers?
Its sole caller, virtio_gpu_panic_alloc_cmd_resp(), does not check vbuf
before reading vbuf->buf:
drivers/gpu/drm/virtio/virtgpu_vq.c:virtio_gpu_panic_alloc_cmd_resp() {
vbuf = virtio_gpu_panic_get_vbuf(vgdev, cmd_size);
*vbuffer_p = vbuf;
return (struct virtio_gpu_command *)vbuf->buf;
}
Both callers of virtio_gpu_panic_alloc_cmd_resp(),
virtio_gpu_panic_cmd_resource_flush() and
virtio_gpu_panic_cmd_transfer_to_host_2d(), also pass the returned cmd_p to
memset() and dereference vbuf->objs without checking for NULL.
[1] https://sashiko.dev/#/bug/linux-c6d68f26-60e8-47ae-8a01-6ff4145223a3
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_108E6BD0C2683FCD678A1B68C99A5CFFF806@qq.com?part=1
prev parent reply other threads:[~2026-12-02 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:41 [PATCH] virtio: Handle vbuf allocation failure in panic path Syh-Xiong
2026-12-02 13:53 ` 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-245908@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=1850029304@qq.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eperezma@redhat.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