All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] util/vhost-user-server: fix potential NULL dereference in vu_message_read
@ 2026-09-15 13:02 Николай Зорин
  2026-09-15 18:35 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Николай Зорин @ 2026-09-15 13:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, mst

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(-)

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] util/vhost-user-server: fix potential NULL dereference in vu_message_read
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2026-09-15 18:35 UTC (permalink / raw)
  To: Николай Зорин
  Cc: qemu-devel, kwolf, mst

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-15 18:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.