From: sashiko-bot@kernel.org
To: "Hao Zhang" <hao_zhang_kdev@163.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2 2/2] KVM: selftests: Verify failed IOAPIC delivery preserves state
Date: Mon, 10 Aug 2026 06:33:10 +0000 [thread overview]
Message-ID: <20260810063310.8F81B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <anluERKCXkZglDEe@192.168.1.215>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Uninitialized `struct kvm_irqchip` passed to `KVM_GET_IRQCHIP` ioctl leaks stack memory to the kernel, triggering memory sanitizer errors.
--
--- Patch [2]: [PATCH v2 2/2] KVM: selftests: Verify failed IOAPIC delivery preserves state ---
commit bdb3cd0c37699df03cd34fd3d221e67589076c39
Author: Hao Zhang <zhanghao1@kylinos.cn>
KVM: selftests: Verify failed IOAPIC delivery preserves state
This commit adds regression coverage for I/O APIC interrupt delivery when no
local APIC can accept the interrupt. It verifies that failed delivery behaves
correctly for both level-triggered and edge-triggered interrupts.
> diff --git a/tools/testing/selftests/kvm/x86/ioapic_state_test.c b/tools/testing/selftests/kvm/x86/ioapic_state_test.c
> new file mode 100644
> index 0000000000000..3613a67f4b217
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/x86/ioapic_state_test.c
[ ... ]
> +static void set_undeliverable_ioapic_entry(struct kvm_vm *vm,
> + bool level_triggered)
> +{
> + struct kvm_irqchip irqchip;
> +
> + get_ioapic(vm, &irqchip);
[Severity: Medium]
Will this leak uninitialized stack memory to the kernel?
Since KVM_GET_IRQCHIP is defined as _IOWR, the kernel uses memdup_user() to
copy the entire struct kvm_irqchip from userspace. Because the struct contains
a 512-byte union and is declared uninitialized on the stack, passing it to the
kernel will trigger memory sanitizer or Valgrind errors during testing.
Could this be zero-initialized?
[ ... ]
> +static void test_no_remote_irr_for_undelivered_interrupt(void)
> +{
> + struct kvm_irq_level irq = {
> + .irq = TEST_IOAPIC_PIN,
> + .level = 1,
> + };
> + struct kvm_irqchip irqchip;
> + struct kvm_vm *vm;
> +
> + vm = vm_create_barebones();
> + vm_create_irqchip(vm);
> +
> + set_undeliverable_ioapic_entry(vm, true);
> +
> + vm_ioctl(vm, KVM_IRQ_LINE_STATUS, &irq);
> + TEST_ASSERT(irq.status == -1,
> + "Expected failed interrupt delivery, got %d", irq.status);
> +
> + get_ioapic(vm, &irqchip);
[Severity: Medium]
Does this struct also need to be zero-initialized to prevent memory
sanitizer errors when calling the KVM_GET_IRQCHIP ioctl?
[ ... ]
> +static void test_undelivered_edge_interrupt_stays_pending(void)
> +{
> + struct kvm_irq_level irq = {
> + .irq = TEST_IOAPIC_PIN,
> + .level = 1,
> + };
> + struct kvm_irqchip irqchip;
> + struct kvm_vm *vm;
> +
> + vm = vm_create_barebones();
> + vm_create_irqchip(vm);
> +
> + set_undeliverable_ioapic_entry(vm, false);
> +
> + vm_ioctl(vm, KVM_IRQ_LINE_STATUS, &irq);
> + TEST_ASSERT(irq.status == -1,
> + "Expected failed interrupt delivery, got %d", irq.status);
> +
> + get_ioapic(vm, &irqchip);
[Severity: Medium]
Does this uninitialized struct also need to be zero-initialized for the
same reason?
--
Sashiko AI review · https://sashiko.dev/#/patchset/anls-aUppuiFolpS@192.168.1.215?part=2
next prev parent reply other threads:[~2026-08-10 6:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 6:17 [PATCH 1/2] KVM: x86: ioapic: Update state only after successful delivery Hao Zhang
2026-08-10 6:22 ` [PATCH v2 2/2] KVM: selftests: Verify failed IOAPIC delivery preserves state Hao Zhang
2026-08-10 6:33 ` sashiko-bot [this message]
2026-08-10 6:45 ` [PATCH 1/2] KVM: x86: ioapic: Update state only after successful delivery sashiko-bot
2026-08-10 8:34 ` Huang, Kai
2026-08-10 9:39 ` hao_zhang_kdev
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=20260810063310.8F81B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hao_zhang_kdev@163.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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