From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Николай Зорин" <zorin@swemel.ru>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, mst@redhat.com
Subject: Re: [PATCH] util/vhost-user-server: fix potential NULL dereference in vu_message_read
Date: Tue, 15 Sep 2026 14:35:38 -0400 [thread overview]
Message-ID: <20260915183538.GA105129@fedora> (raw)
In-Reply-To: <a15f7b76-0ffc-418b-85dc-219e351d9794@swemel.ru>
[-- Attachment #1: Type: text/plain, Size: 1756 bytes --]
On Tue, Sep 15, 2026 at 04:02:31PM +0300, Николай Зорин wrote:
> The `vu_message_read()` function initializes `local_err` to `NULL`.
> If `server->ioc` is `NULL`, the execution jumps to the `if (!ioc)`
> branch and invokes `error_report_err(local_err)`.
>
> Passing a guaranteed `NULL` pointer to `error_report_err()` leads
> to a crash because `error_get_pretty(err)` will attempt to dereference
> `err->msg`, triggering a Segmentation Fault (`SIGSEGV`).
>
> Since `server->ioc` shouldn't be `NULL` during an active coroutine
> execution, this error block is effectively dead code, but it represents
> a dangerous pattern left over from copy-pasting or incomplete refactoring.
>
> Fix this by removing the incorrect `error_report_err(local_err)` call
> inside the `if (!ioc)` block. The `local_err` variable itself is preserved
> as it is used later in the function for actual I/O error handling.
>
> Signed-off-by: Nikolay N Zorin <zorin@swemel.ru>
> ---
> util/vhost-user-server.c | 1 -
> 1 file changed, 1 deletion(-)
This was fixed by commit 34523df31962 ("util/vhost-user-server:
vu_message_read(): improve error handling") and is no longer present in
qemu.git/master.
Please check against qemu.git/master to avoid duplicating work.
Thanks,
Stefan
>
> diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c
> index f30f6b3e..a4b2c1d0 100644
> --- a/util/vhost-user-server.c
> +++ b/util/vhost-user-server.c
> @@ -15,7 +15,6 @@ static bool coroutine_fn vu_message_read(VuDev *vu_dev,
> int conn_fd, VhostUserMs
>
> vmsg->fd_num = 0;
> if (!ioc) {
> - error_report_err(local_err);
> goto fail;
> }
>
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-09-15 18:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 13:02 [PATCH] util/vhost-user-server: fix potential NULL dereference in vu_message_read Николай Зорин
2026-09-15 18:35 ` Stefan Hajnoczi [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=20260915183538.GA105129@fedora \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--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.