[PATCH] qemu: prevent SIGSEGV in qemuProcessHandleDumpCompleted

Nikolai Barybin posted 1 patch 10 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20230627084359.171276-1-nikolai.barybin@virtuozzo.com
src/qemu/qemu_process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] qemu: prevent SIGSEGV in qemuProcessHandleDumpCompleted
Posted by Nikolai Barybin 10 months, 1 week ago
If VIR_ASYNC_JOB_NONE flag is present, job.current is equal
to NULL, which leads to SIGSEGV. Thus, this check should be
moved up.

Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com>
---
 src/qemu/qemu_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d3b1bdf6a4..db06991450 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1601,11 +1601,11 @@ qemuProcessHandleDumpCompleted(qemuMonitor *mon G_GNUC_UNUSED,
               vm, vm->def->name, stats, NULLSTR(error));
 
     jobPriv = vm->job->privateData;
-    privJobCurrent = vm->job->current->privateData;
     if (vm->job->asyncJob == VIR_ASYNC_JOB_NONE) {
         VIR_DEBUG("got DUMP_COMPLETED event without a dump_completed job");
         goto cleanup;
     }
+    privJobCurrent = vm->job->current->privateData;
     jobPriv->dumpCompleted = true;
     privJobCurrent->stats.dump = *stats;
     vm->job->error = g_strdup(error);
-- 
2.39.3
Re: [PATCH] qemu: prevent SIGSEGV in qemuProcessHandleDumpCompleted
Posted by Jiri Denemark 10 months, 1 week ago
On Tue, Jun 27, 2023 at 11:43:58 +0300, Nikolai Barybin wrote:
> If VIR_ASYNC_JOB_NONE flag is present, job.current is equal
> to NULL, which leads to SIGSEGV. Thus, this check should be
> moved up.
> 
> Signed-off-by: Nikolai Barybin <nikolai.barybin@virtuozzo.com>
> ---
>  src/qemu/qemu_process.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index d3b1bdf6a4..db06991450 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -1601,11 +1601,11 @@ qemuProcessHandleDumpCompleted(qemuMonitor *mon G_GNUC_UNUSED,
>                vm, vm->def->name, stats, NULLSTR(error));
>  
>      jobPriv = vm->job->privateData;
> -    privJobCurrent = vm->job->current->privateData;
>      if (vm->job->asyncJob == VIR_ASYNC_JOB_NONE) {
>          VIR_DEBUG("got DUMP_COMPLETED event without a dump_completed job");
>          goto cleanup;
>      }
> +    privJobCurrent = vm->job->current->privateData;
>      jobPriv->dumpCompleted = true;
>      privJobCurrent->stats.dump = *stats;
>      vm->job->error = g_strdup(error);

Right, and it used to be this way until commit v8.0.0-427-gf304de0df6

Fixes: v8.0.0-427-gf304de0df6
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

And pushed, thanks.