mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yuho Choi <oss.patchbox@gmail.com>
To: Fei Li <fei1.li@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shuo Liu <shuo.a.liu@intel.com>,
	linux-kernel@vger.kernel.org, Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH v1] virt: acrn: Don't free a VM the hypervisor refused to destroy
Date: Tue, 10 Nov 2026 20:51:46 -0500	[thread overview]
Message-ID: <20261111015250.1037116-2-oss.patchbox@gmail.com> (raw)

acrn_dev_release() calls acrn_vm_destroy() and then frees the VM
whether or not it was destroyed.

Since commit 4c4c1257b844 ("virt: acrn: Do hcall_destroy_vm() before
resource release"), acrn_vm_destroy() returns early when
hcall_destroy_vm() fails, so that the VM can be destroyed again later.
The VM then stays on acrn_vm_list, and its ioreq clients and irqfds
still point to it. That commit names a real-time VM as a case where the
hypervisor refuses, since it can keep running without the Service VM.
The hypervisor also only destroys a paused VM, so the same happens when
the device model exits without pausing the VM.

Once the VM is freed, ioreq_dispatcher() still walks acrn_vm_list on
the next I/O request notification and dereferences the freed VM.

Leak the VM instead when it could not be destroyed.

Fixes: 4c4c1257b844 ("virt: acrn: Do hcall_destroy_vm() before resource release")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64 defconfig with ACRN_HSM, W=1); I have no
ACRN setup to test it on.

 drivers/virt/acrn/hsm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
index f170ff4617fdd..8403859e0c868 100644
--- a/drivers/virt/acrn/hsm.c
+++ b/drivers/virt/acrn/hsm.c
@@ -427,8 +427,13 @@ static int acrn_dev_release(struct inode *inode, struct file *filp)
 {
 	struct acrn_vm *vm = filp->private_data;
 
-	acrn_vm_destroy(vm);
-	kfree(vm);
+	/*
+	 * If the hypervisor refused to destroy the VM, it is still on
+	 * acrn_vm_list and its ioreq clients and irqfds still use it, so
+	 * leak it.
+	 */
+	if (!acrn_vm_destroy(vm))
+		kfree(vm);
 	return 0;
 }
 

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


                 reply	other threads:[~2026-11-11  1:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261111015250.1037116-2-oss.patchbox@gmail.com \
    --to=oss.patchbox@gmail.com \
    --cc=fei1.li@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuo.a.liu@intel.com \
    /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

all inboxes | Powered by JetHome®