[PATCH 08/39] KVM: Device assignment: Check for privileges before assigning irq

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Avi Kivity
Date: Thursday, September 25, 2008 - 4:54 am

From: Amit Shah <amit.shah@qumranet.com>

Even though we don't share irqs at the moment, we should ensure
regular user processes don't try to allocate system resources.

We check for capability to access IO devices (CAP_SYS_RAWIO) before
we request_irq on behalf of the guest.

Noticed by Avi.

Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
 arch/x86/kvm/x86.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4a03375..fffdf4f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -191,6 +191,11 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
 		  kvm_assigned_dev_interrupt_work_handler);
 
 	if (irqchip_in_kernel(kvm)) {
+		if (!capable(CAP_SYS_RAWIO)) {
+			return -EPERM;
+			goto out;
+		}
+
 		if (assigned_irq->host_irq)
 			match->host_irq = assigned_irq->host_irq;
 		else
-- 
1.6.0.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 06/39] KVM: fix i8259 reset irq acking, Avi Kivity, (Thu Sep 25, 4:54 am)
[PATCH 08/39] KVM: Device assignment: Check for privileges ..., Avi Kivity, (Thu Sep 25, 4:54 am)
[PATCH 13/39] KVM: SVM: Fix typo, Avi Kivity, (Thu Sep 25, 4:54 am)
[PATCH 19/39] KVM: Load real mode segments correctly, Avi Kivity, (Thu Sep 25, 4:54 am)
[PATCH 26/39] KVM: MMU: Add generic shadow walker, Avi Kivity, (Thu Sep 25, 4:54 am)
[PATCH 37/39] KVM: add MC5_MISC msr read support, Avi Kivity, (Thu Sep 25, 4:55 am)