* [PATCH] KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer
@ 2025-05-30 9:16 Marc Zyngier
2025-05-30 9:27 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2025-05-30 9:16 UTC (permalink / raw)
To: kvmarm, linux-arm-kernel
Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu,
Dan Carpenter, Jing Zhang
Dan reports that iterating over a device ITEs can legitimately lead
to a NULL pointer, and that the NULL check is placed *after* the
pointer has already been dereferenced.
Hoist the pointer check as early as possible and be done with it.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 30deb51a677b ("KVM: arm64: vgic-its: Add debugfs interface to expose ITS tables")
Link: https://lore.kernel.org/r/aDBylI1YnjPatAbr@stanley.mountain
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Jing Zhang <jingzhangos@google.com>
---
arch/arm64/kvm/vgic/vgic-debug.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/vgic/vgic-debug.c b/arch/arm64/kvm/vgic/vgic-debug.c
index f8425f381de97..2684f273d9e17 100644
--- a/arch/arm64/kvm/vgic/vgic-debug.c
+++ b/arch/arm64/kvm/vgic/vgic-debug.c
@@ -490,6 +490,9 @@ static int vgic_its_debug_show(struct seq_file *s, void *v)
struct its_device *dev = iter->dev;
struct its_ite *ite = iter->ite;
+ if (!ite)
+ return 0;
+
if (list_is_first(&ite->ite_list, &dev->itt_head)) {
seq_printf(s, "\n");
seq_printf(s, "Device ID: 0x%x, Event ID Range: [0 - %llu]\n",
@@ -498,7 +501,7 @@ static int vgic_its_debug_show(struct seq_file *s, void *v)
seq_printf(s, "-----------------------------------------------\n");
}
- if (ite && ite->irq && ite->collection) {
+ if (ite->irq && ite->collection) {
seq_printf(s, "%8u %8u %8u %8u %8u %2d\n",
ite->event_id, ite->irq->intid, ite->irq->hwintid,
ite->collection->target_addr,
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer
2025-05-30 9:16 [PATCH] KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer Marc Zyngier
@ 2025-05-30 9:27 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2025-05-30 9:27 UTC (permalink / raw)
To: kvmarm, linux-arm-kernel, Marc Zyngier
Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu,
Dan Carpenter, Jing Zhang
On Fri, 30 May 2025 10:16:47 +0100, Marc Zyngier wrote:
> Dan reports that iterating over a device ITEs can legitimately lead
> to a NULL pointer, and that the NULL check is placed *after* the
> pointer has already been dereferenced.
>
> Hoist the pointer check as early as possible and be done with it.
>
>
> [...]
Applied to next, thanks!
[1/1] KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer
commit: 4d62121ce9b58ea23c8d62207cbc604e98ecdc0a
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-30 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-30 9:16 [PATCH] KVM: arm64: vgic-debug: Avoid dereferencing NULL ITE pointer Marc Zyngier
2025-05-30 9:27 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).