From: sashiko-bot@kernel.org
To: "Yuchao Zhang" <ndaugoing@gmail.com>
Cc: "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>,
kvmarm@lists.linux.dev
Subject: Re: [PATCH] KVM: selftests: arm64: Add test for cross-vCPU LPI disable race
Date: Tue, 22 Sep 2026 10:29:58 +0000 [thread overview]
Message-ID: <20260922102959.41FFA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922101632.39497-1-ndaugoing@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] kvm: selftests: buffer overflow in configure_lpis() via large event_ids
- [Medium] kvm: selftests: ITS command error due to INVALL/SYNC on unmapped collection
- [Medium] kvm: selftests: silently ignored MSI injection failures in signal_lpi()
--
commit c5682a23bdbe7c62a7e95d362e2d340ff25c1e42
Author: Yuchao Zhang <ndaugoing@gmail.com>
KVM: selftests: arm64: Add test for cross-vCPU LPI disable race
This commit adds a selftest to validate the behavior of remote LPI
disabling while the target vCPU has in-flight or overflowing LPIs. It
configures an ITS with multiple LPIs targeting vCPU 0, while vCPU 1
toggles GICR_CTLR.EnableLPIs.
> diff --git a/tools/testing/selftests/kvm/arm64/vgic_lpi_disable.c b/tools/testing/selftests/kvm/arm64/vgic_lpi_disable.c
> new file mode 100644
> index 0000000000000..0781349192288
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/arm64/vgic_lpi_disable.c
> @@ -0,0 +1,401 @@
[ ... ]
> +static void guest_setup_its_mappings(void)
> +{
> + u32 device_id, event_id, intid = GIC_LPI_OFFSET;
> + u32 nr_events = test_data.nr_event_ids;
> + u32 nr_devices = test_data.nr_devices;
> +
> + /* Map collection 0 to TARGET_VCPU_ID */
> + its_send_mapc_cmd(test_data.cmdq_base_va, TARGET_VCPU_ID, TARGET_VCPU_ID, true);
> +
> + /* Map all LPIs to TARGET_VCPU_ID to force LR overflow */
[ ... ]
> +static void guest_invalidate_all_rdists(void)
> +{
> + int i;
> +
> + for (i = 0; i < test_data.nr_cpus; i++)
> + its_send_invall_cmd(test_data.cmdq_base_va, i);
> +}
[Severity: Medium]
Will sending an INVALL command for CPU ID 1 act as a command error since
collection 1 was never mapped?
In guest_setup_its_mappings(), only collection 0 is mapped to TARGET_VCPU_ID,
but this loop iterates over all CPUs (collections 0 and 1) and sends INVALL.
[ ... ]
> +static void guest_setup_gic(void)
> +{
[ ... ]
> + guest_setup_its_mappings();
> + guest_invalidate_all_rdists();
> +
> + /* SYNC to ensure ITS setup is complete */
> + for (cpuid = 0; cpuid < test_data.nr_cpus; cpuid++)
> + its_send_sync_cmd(test_data.cmdq_base_va, cpuid);
> +}
[Severity: Medium]
Similarly, does issuing a SYNC command for cpuid 1 cause an architectural
command error here, given that collection 1 remains unmapped?
This might cause the virtual ITS command queue to stall.
[ ... ]
> +static void configure_lpis(void)
> +{
> + size_t nr_lpis = test_data.nr_devices * test_data.nr_event_ids;
> + u8 *tbl = addr_gpa2hva(vm, test_data.lpi_prop_table);
> + size_t i;
> +
> + for (i = 0; i < nr_lpis; i++) {
> + tbl[i] = LPI_PROP_DEFAULT_PRIO |
> + LPI_PROP_GROUP1 |
> + LPI_PROP_ENABLED;
> + }
> +}
[Severity: Medium]
Can this loop overflow the lpi_prop_table allocation?
The table is allocated a fixed 64KB size in setup_test_data(), but
test_data.nr_event_ids is read directly from the command line argument in
main() via atoi_positive(). A large user input could cause an out-of-bounds
write here since the value isn't bounds-checked to fit within the region.
[ ... ]
> +static void signal_lpi(u32 device_id, u32 event_id)
> +{
> + gpa_t db_addr = GITS_BASE_GPA + GITS_TRANSLATER;
> +
> + struct kvm_msi msi = {
> + .address_lo = db_addr,
> + .address_hi = db_addr >> 32,
> + .data = event_id,
> + .devid = device_id,
> + .flags = KVM_MSI_VALID_DEVID,
> + };
> +
> + __vm_ioctl(vm, KVM_SIGNAL_MSI, &msi);
> +}
[Severity: Medium]
Is it safe to ignore the return value of __vm_ioctl() here?
If KVM_SIGNAL_MSI fails (for example, if the ITS command queue stalls due
to the unmapped collection mentioned earlier), the failure is silently masked.
This could cause the test to spin without triggering the intended overflow
path, falsely reporting success on a broken test environment.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922101632.39497-1-ndaugoing@gmail.com?part=1
next prev parent reply other threads:[~2026-09-22 10:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 4:02 [PATCH v2 0/1] KVM: arm64: vgic: fix UAF/crash on remote LPI disable zjamg
2026-09-18 4:02 ` [PATCH v2] KVM: arm64: vgic: Do not remove in-flight LPIs from AP list on disable zjamg
2026-09-18 7:22 ` Fuad Tabba
2026-09-18 11:50 ` Yuchao Zhang
2026-09-18 11:58 ` Fuad Tabba
2026-09-18 19:15 ` Oliver Upton
2026-09-20 23:54 ` Marc Zyngier
2026-09-20 1:49 ` [PATCH v3 0/1] KVM: arm64: vgic: Drop last_lr_irq and serialize overflow EOI replay Yuchao Zhang
2026-09-20 1:49 ` [PATCH v3] " Yuchao Zhang
2026-09-20 23:47 ` [PATCH v3 0/1] " Marc Zyngier
2026-09-22 10:16 ` Yuchao Zhang
2026-09-22 10:16 ` [PATCH] KVM: selftests: arm64: Add test for cross-vCPU LPI disable race Yuchao Zhang
2026-09-22 10:29 ` sashiko-bot [this message]
2026-09-22 10:53 ` Yuchao Zhang
2026-09-22 10:53 ` [PATCH v2] " Yuchao Zhang
2026-09-22 11:03 ` sashiko-bot
2026-09-22 11:24 ` Yuchao Zhang
2026-09-22 17:08 ` Fuad Tabba
2026-09-22 17:05 ` [PATCH v3 0/1] KVM: arm64: vgic: Drop last_lr_irq and serialize overflow EOI replay Fuad Tabba
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=20260922102959.41FFA1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=ndaugoing@gmail.com \
--cc=oupton@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 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.