All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Николай Зорин" <zorin@swemel.ru>
Cc: qemu-devel@nongnu.org, thuth@redhat.com, stefanha@redhat.com,
	kwolf@redhat.com
Subject: Re: PATCH] hw/s390x/s390-hypercall: fix potential NULL dereference in handle_virtio_ccw_notify
Date: Tue, 15 Sep 2026 12:53:24 -0400	[thread overview]
Message-ID: <20260915125119-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <13ad0871-44dd-40eb-aad1-d08cc2d7dfe5@swemel.ru>

On Tue, Sep 15, 2026 at 07:17:28PM +0300, Николай Зорин wrote:
> SWSA#4992cdf0-415c-45c1-be1a-71213467347d
> 
> The `virtio_ccw_get_vdev()` function can return a `NULL` pointer if the
> corresponding subchannel driver data (`sch->driver_data`) is not initialized
> or has been cleared.

and when does this happen?

> If `vdev` is `NULL`, passing it directly into `virtio_queue_get_num(vdev,
> vq_idx)`
> results in a `NULL` pointer dereference, which can lead to a hypervisor
> crash or unexpected termination of the QEMU process.
> 
> Fix this by adding an explicit check for `!vdev` before verifying the
> queue index and its capacity, returning `-EINVAL` early if the device
> is missing or not bound to the subchannel.


Please do not use this style with `` - there's no reason to. Just
say NULL -EINVAL etc normally.

> 
> Signed-off-by: Nikolay N Zorin <zorin@swemel.ru>
> ---
>  hw/s390x/s390-hypercall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-hypercall.c b/hw/s390x/s390-hypercall.c
> index ac1b08b2..fd2972c0 100644
> --- a/hw/s390x/s390-hypercall.c
> +++ b/hw/s390x/s390-hypercall.c
> @@ -44,7 +44,7 @@ static int handle_virtio_ccw_notify(uint64_t subch_id,
> uint64_t data)
>      }
> 
>      vdev = virtio_ccw_get_vdev(sch);
> -    if (vq_idx >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, vq_idx))
> {
> +    if (!vdev || vq_idx >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev,
> vq_idx)) {
>          return -EINVAL;
>      }
> -- 
> 2.43.0



      parent reply	other threads:[~2026-09-15 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 16:17 PATCH] hw/s390x/s390-hypercall: fix potential NULL dereference in handle_virtio_ccw_notify Николай Зорин
2026-09-15 16:32 ` Thomas Huth
2026-09-15 16:42   ` Николай Зорин
2026-09-15 16:50     ` Thomas Huth
2026-09-15 17:00       ` Николай Зорин
2026-09-15 17:02         ` Michael S. Tsirkin
2026-09-15 17:00     ` Michael S. Tsirkin
2026-09-15 16:53 ` 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=20260915125119-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=zorin@swemel.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.