Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tarun Sahu" <tarunsahu@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH v2 04/10] kvm: kvm_luo: Allow kvm preservation with LUO
Date: Fri, 05 Jun 2026 17:26:34 +0000	[thread overview]
Message-ID: <20260605172634.95C811F00893@smtp.kernel.org> (raw)
In-Reply-To: <8730c0e11acbd0d645a8b7187cd5cd7de373380e.1780676742.git.tarunsahu@google.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] KVM live update silently drops the VM type on non-x86 architectures, leading to incorrect VM initialization during restore.
- [High] Double free attempt of KHO serialized data on the successful retrieve path triggers a kernel warning.
- [Medium] Debugfs directory name collision for restored VMs silently drops statistics for new VMs.
--

commit ded3fe4d8e96caf44b395f665f8fedc9e63e601b
Author: Tarun Sahu <tarunsahu@google.com>

kvm: kvm_luo: Allow kvm preservation with LUO

Introduce KVM VM preservation support for Live Update Orchestrator.
This registers an LUO file handler for KVM files to serialize and
deserialize necessary VM state across live updates.

> diff --git a/virt/kvm/kvm_luo.c b/virt/kvm/kvm_luo.c
> new file mode 100644
> index 0000000000000..25619f94ace5b
> --- /dev/null
> +++ b/virt/kvm/kvm_luo.c
[ ... ]
> +static int kvm_luo_preserve(struct liveupdate_file_op_args *args)
> +{
[ ... ]
> +#ifdef CONFIG_X86
> +	ser->type = kvm->arch.vm_type;
> +#else
> +	ser->type = 0;

[Severity: High]
Does hardcoding the VM type to 0 on non-x86 architectures discard required
state? 

For instance, on ARM64, the VM type parameter encodes architectural
information such as the Intermediate Physical Address (IPA) size and
protection flags. 

Will restoring the VM with type 0 cause the new kernel to initialize the
VM with default settings, potentially leading to a mismatched memory layout?

> +#endif
> +
> +	args->serialized_data = virt_to_phys(ser);
> +
> +	return 0;
> +}
> +
> +static atomic_t restored_vm_id = ATOMIC_INIT(0);
> +
> +static int kvm_luo_retrieve(struct liveupdate_file_op_args *args)
> +{
> +	char fdname[ITOA_MAX_LEN + 1];
[ ... ]
> +	snprintf(fdname, sizeof(fdname), "%d",
> +		 atomic_inc_return(&restored_vm_id));

[Severity: Medium]
Since standard VMs use their native file descriptor numbers as fdname, and
those typically start from low numbers, will this auto-incrementing counter
guarantee namespace collisions? 

A collision here would result in a duplicate directory error in
kvm_create_vm_debugfs(), which would cause debugfs statistics for newly
created VMs to be skipped.

> +
> +	file = kvm_create_vm_file(ser->type, fdname);
[ ... ]
> +static void kvm_luo_finish(struct liveupdate_file_op_args *args)
> +{
> +	struct kvm_luo_ser *ser;
> +
> +	/*
> +	 * If retrieve_status is true or set to error, nothing to do here.
> +	 * Already cleaned up in kvm_luo_retrieve().
> +	 */
> +	if (args->retrieve_status)
> +		return;
> +
> +	if (!args->serialized_data)
> +		return;
> +
> +	ser = phys_to_virt(args->serialized_data);
> +	kho_restore_free(ser);

[Severity: High]
Can this result in a double-free on the successful retrieve path?

In kvm_luo_retrieve(), kho_restore_free() is explicitly called on success
before returning 0:

	args->file = file;
	kho_restore_free(ser);

	kvm_uevent_notify_vm_create(kvm);
	return 0;

Since the retrieve is successful, args->retrieve_status will be 0 here,
and this function will call kho_restore_free() again on the same
serialized data.

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1780676742.git.tarunsahu@google.com?part=4

  reply	other threads:[~2026-06-05 17:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1780676742.git.tarunsahu@google.com>
2026-06-05 17:08 ` [RFC PATCH v2 01/10] liveupdate: luo_file: Add internal APIs for file preservation Tarun Sahu
2026-06-05 17:24   ` sashiko-bot
2026-06-07  0:41     ` tarunsahu
2026-06-07  0:35   ` tarunsahu
2026-06-05 17:08 ` [RFC PATCH v2 02/10] liveupdate: Add LIVEUPDATE_GUEST_MEMFD config option Tarun Sahu
2026-06-05 17:08 ` [RFC PATCH v2 03/10] kvm: Prepare core VM structs and helpers for LUO support Tarun Sahu
2026-06-05 17:21   ` sashiko-bot
2026-06-22 23:59   ` Ackerley Tng
2026-06-05 17:08 ` [RFC PATCH v2 04/10] kvm: kvm_luo: Allow kvm preservation with LUO Tarun Sahu
2026-06-05 17:26   ` sashiko-bot [this message]
2026-06-08 16:13     ` tarunsahu
2026-06-05 17:08 ` [RFC PATCH v2 05/10] kvm: guest_memfd: Move internal definitions and helper to new header Tarun Sahu
2026-06-05 17:08 ` [RFC PATCH v2 06/10] kvm: guest_memfd: Add support for freezing and unfreezing mappings Tarun Sahu
2026-06-05 17:21   ` sashiko-bot
2026-06-08 18:20     ` tarunsahu
2026-06-22 23:54   ` Ackerley Tng
2026-06-23  0:09     ` Sean Christopherson
2026-06-05 17:08 ` [RFC PATCH v2 07/10] kvm: guest_memfd_luo: add support for guest_memfd preservation Tarun Sahu
2026-06-05 17:25   ` sashiko-bot
2026-06-08 18:22     ` tarunsahu
2026-06-22 23:27   ` Ackerley Tng
2026-06-05 17:08 ` [RFC PATCH v2 08/10] docs: add documentation for guest_memfd preservation via LUO Tarun Sahu
2026-06-05 17:08 ` [RFC PATCH v2 09/10] selftests: kvm: Split ____vm_create() to expose init helpers Tarun Sahu
2026-06-05 17:08 ` [RFC PATCH v2 10/10] selftests: kvm: Add guest_memfd_preservation_test Tarun Sahu
2026-06-05 17:22   ` sashiko-bot
2026-06-08 18:26     ` tarunsahu
2026-06-22 23:01   ` Ackerley Tng

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=20260605172634.95C811F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tarunsahu@google.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