]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: s390: reinjection of irqs can fail in the tpi handler
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Wed, 4 Feb 2015 14:59:11 +0000 (15:59 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Mon, 4 May 2015 15:06:38 +0000 (16:06 +0100)
commit 15462e37ca848abac7477dece65f8af25febd744 upstream.

The reinjection of an I/O interrupt can fail if the list is at the limit
and between the dequeue and the reinjection, another I/O interrupt is
injected (e.g. if user space floods kvm with I/O interrupts).

This patch avoids this memory leak and returns -EFAULT in this special
case. This error is not recoverable, so let's fail hard. This can later
be avoided by not dequeuing the interrupt but working directly on the
locked list.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
arch/s390/kvm/interrupt.c
arch/s390/kvm/kvm-s390.h
arch/s390/kvm/priv.c

index f19702fc89eca91073ff015e03c79fa1124c414e..be5fb350d25531bcc4a5f0c0addfa0ddd13822db 100644 (file)
@@ -1007,10 +1007,10 @@ int kvm_s390_inject_vm(struct kvm *kvm,
        return rc;
 }
 
-void kvm_s390_reinject_io_int(struct kvm *kvm,
+int kvm_s390_reinject_io_int(struct kvm *kvm,
                              struct kvm_s390_interrupt_info *inti)
 {
-       __inject_vm(kvm, inti);
+       return __inject_vm(kvm, inti);
 }
 
 int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
index a8655ed31616746adc2fb2e7e454b22451e2f60e..3d08a076729febe77838e1a8f0a946960b5a5438 100644 (file)
@@ -143,8 +143,8 @@ int __must_check kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
 int __must_check kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
 struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
                                                    u64 cr6, u64 schid);
-void kvm_s390_reinject_io_int(struct kvm *kvm,
-                             struct kvm_s390_interrupt_info *inti);
+int kvm_s390_reinject_io_int(struct kvm *kvm,
+                            struct kvm_s390_interrupt_info *inti);
 int kvm_s390_mask_adapter(struct kvm *kvm, unsigned int id, bool masked);
 
 /* implemented in priv.c */
index a0796549077903338f359a50b17b9dcecb742eda..8a5156d85c70ecbcb09a4dee32f808cf4dad0ec9 100644 (file)
@@ -278,7 +278,10 @@ reinject_interrupt:
         * instruction is suppressed from the guest's view: reinject the
         * interrupt.
         */
-       kvm_s390_reinject_io_int(vcpu->kvm, inti);
+       if (kvm_s390_reinject_io_int(vcpu->kvm, inti)) {
+               kfree(inti);
+               rc = -EFAULT;
+       }
        /* don't set the cc, a pgm irq was injected or we drop to user space */
        return rc ? -EFAULT : 0;
 }