Skip to contentSkip to conversation

x86/hvm: Allow guest_request vm_events coming from userspace

PATCH Superseded Alexandru Isaila 4 participants 5 messages Aug 1, 2017 – Aug 2, 2017

v2 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/hvm: Allow guest_request vm_events coming from userspace

Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). This is a use case in communication between a userspace application in the guest and the introspection application in dom0.

---
Changes since V1:
- Added Fallthrough check on mode == 2

---
 xen/arch/x86/hvm/hypercall.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/x86/hvm/hypercall.c +6 -0
index e7238ce..1c067c3 100644
@@ -152,9 +152,15 @@ int hvm_hypercall(struct cpu_user_regs *regs)
     {
     case 8:
         eax = regs->rax;
+        if ( eax == __HYPERVISOR_hvm_op &&
+             regs->rdi == HVMOP_guest_request_vm_event )
+            break;
         /* Fallthrough to permission check. */
     case 4:
     case 2:
+        if ( mode != 8 && eax == __HYPERVISOR_hvm_op &&
+             regs->ebx == HVMOP_guest_request_vm_event )
+            break;
         if ( unlikely(hvm_get_cpl(curr)) )
         {
     default:
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 8 lines · Alexandru Isaila

Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). This is a use case in communication between a userspace application in the guest and the introspection application in dom0.

This issue has been argued several times before, and while I am in favour of the change, there is a legitimate argument that it breaks one of our security boundaries.

One intermediate option comes to mind however.

Could we introduce a new monitor op which permits the use of HVMOP_guest_request_vm_event from userspace? This way, it requires a positive action on behalf of the introspection agent to relax the CPL check, rather than having the CPL check unconditionally relaxed.

I think this would be sufficient to alleviate the previous objections.

~Andrew

Quoted 18 lines

---
Changes since V1:
- Added Fallthrough check on mode == 2

---
 xen/arch/x86/hvm/hypercall.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/x86/hvm/hypercall.c +2 -0
index e7238ce..1c067c3 100644
@@ -152,9 +152,15 @@ int hvm_hypercall(struct cpu_user_regs *regs)
     {
     case 8:
         eax = regs->rax;
+        if ( eax == __HYPERVISOR_hvm_op &&
+             regs->rdi == HVMOP_guest_request_vm_event )

xen/arch/x86/hvm/hypercall.c int hvm_hypercall(struct cpu_user_regs *regs) · line 166

Quoted 10 lines
xen/arch/x86/hvm/hypercall.c +4 -0
+            break;
         /* Fallthrough to permission check. */
     case 4:
     case 2:
+        if ( mode != 8 && eax == __HYPERVISOR_hvm_op &&
+             regs->ebx == HVMOP_guest_request_vm_event )
+            break;
         if ( unlikely(hvm_get_cpl(curr)) )
         {
     default:

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw

I'm sure we can to this and use a monitor op together with the HVMOP_guest_request_vm_event event. We have discussed this and have a good idea on how to do it.

~Alex
________________________________________
From: Andrew Cooper <[email protected]>
Sent: Tuesday, August 1, 2017 1:30 PM
To: Alexandru Stefan ISAILA; [email protected]
Cc: [email protected]; Razvan Cojocaru; Tamas K Lengyel
Subject: Re: [PATCH v2] x86/hvm: Allow guest_request vm_events coming from userspace

Quoted 8 lines · Alexandru Isaila

Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). This is a use case in communication between a userspace application in the guest and the introspection application in dom0.

This issue has been argued several times before, and while I am in favour of the change, there is a legitimate argument that it breaks one of our security boundaries.

One intermediate option comes to mind however.

Could we introduce a new monitor op which permits the use of HVMOP_guest_request_vm_event from userspace? This way, it requires a positive action on behalf of the introspection agent to relax the CPL check, rather than having the CPL check unconditionally relaxed.

I think this would be sufficient to alleviate the previous objections.

~Andrew

Quoted 18 lines

---
Changes since V1:
- Added Fallthrough check on mode == 2

---
 xen/arch/x86/hvm/hypercall.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/x86/hvm/hypercall.c +2 -0
index e7238ce..1c067c3 100644
@@ -152,9 +152,15 @@ int hvm_hypercall(struct cpu_user_regs *regs)
     {
     case 8:
         eax = regs->rax;
+        if ( eax == __HYPERVISOR_hvm_op &&
+             regs->rdi == HVMOP_guest_request_vm_event )

xen/arch/x86/hvm/hypercall.c int hvm_hypercall(struct cpu_user_regs *regs) · line 166

Quoted 10 lines
xen/arch/x86/hvm/hypercall.c +4 -0
+            break;
         /* Fallthrough to permission check. */
     case 4:
     case 2:
+        if ( mode != 8 && eax == __HYPERVISOR_hvm_op &&
+             regs->ebx == HVMOP_guest_request_vm_event )
+            break;
         if ( unlikely(hvm_get_cpl(curr)) )
         {
     default:

________________________
This email was scanned by Bitdefender

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Andrew Cooper
Quoted 14 lines · Andrew Cooper
Quoted 8 lines · Alexandru Isaila

Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). This is a use case in communication between a userspace application in the guest and the introspection application in dom0.

This issue has been argued several times before, and while I am in favour of the change, there is a legitimate argument that it breaks one of our security boundaries.

Quoted 6 lines

One intermediate option comes to mind however.

Could we introduce a new monitor op which permits the use of HVMOP_guest_request_vm_event from userspace? This way, it requires a positive action on behalf of the introspection agent to relax the CPL check, rather than having the CPL check unconditionally relaxed.

I agree, it would be required to gate this on a monitor option that is disabled by default.

Tamas

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 17 lines · Tamas K Lengyel
Quoted 16 lines · Andrew Cooper
Quoted 8 lines · Alexandru Isaila

Allow guest userspace code to request that a vm_event be sent out via VMCALL. This functionality seems to be handy for a number of Xen developers, as stated on the mailing list (thread "[Xen-devel] HVMOP_guest_request_vm_event only works from guest in ring0"). This is a use case in communication between a userspace application in the guest and the introspection application in dom0.

This issue has been argued several times before, and while I am in favour of the change, there is a legitimate argument that it breaks one of our security boundaries.

One intermediate option comes to mind however.

Quoted 7 lines
Quoted 4 lines

Could we introduce a new monitor op which permits the use of HVMOP_guest_request_vm_event from userspace? This way, it requires a positive action on behalf of the introspection agent to relax the CPL check, rather than having the CPL check unconditionally relaxed.

I agree, it would be required to gate this on a monitor option that is disabled by default.

That's the way we'll move forward. About that: would you prefer a new libxc function that toggles only the userspace part, or that we add a bool parameter to the existing xc_monitor_guest_request()?

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel