Re: [PATCH v3 1/6] LoongArch: KVM: Check irq validility in kvm_vcpu_ioctl_interrupt()
From: Bibo Mao
Date: Tue May 19 2026 - 09:07:21 EST
On 2026/5/19 下午5:43, Bibo Mao wrote:
Function kvm_vcpu_ioctl_interrupt() can be called from userspace, hereBy AI review, there is still problem if the value of intr is 0x8000000. I should notice this earlier :(
add irq validility cheking in kvm_vcpu_ioctl_interrupt().
Fixes: f45ad5b8aa93 ("LoongArch: KVM: Implement vcpu interrupt operations")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Bibo Mao <maobibo@xxxxxxxxxxx>
---
arch/loongarch/kvm/vcpu.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index e28084c49e68..673977a25138 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -1486,7 +1486,14 @@ void kvm_lose_fpu(struct kvm_vcpu *vcpu)
int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
{
- int intr = (int)irq->irq;
+ int vector, intr = (int)irq->irq;
+
+ vector = intr;
+ if (intr < 0)
+ vector = -intr;
http://sashiko.dev/#/patchset/20260519094308.3983046-1-maobibo%40loongson.cn
Regards
Bibo Mao
+
+ if (vector >= EXCCODE_INT_NUM)
+ return -EINVAL;
if (intr > 0)
kvm_queue_irq(vcpu, intr);