Skip to contentSkip to conversation

x86/pv: Prohibit attempts to initialise a vcpu with EFLAGS.{NT, VM} set

PATCH In review Andrew Cooper 2 participants 2 messages Aug 31, 2017 – Sep 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pv: Prohibit attempts to initialise a vcpu with EFLAGS.{NT, VM} set

Luckily, this isn't a security issue, because the fix for XSA-202 (c/s 0e47f92b072) took a proactive aproach and clobbered these flags on the exit-to-guest path.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/domain.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
xen/arch/x86/domain.c +5 -1
index dbddc53..ced1d2e 100644
@@ -765,7 +765,8 @@ int arch_set_info_guest(
                  !is_canonical_address(c.nat->gs_base_user) ||
                  !is_canonical_address(c.nat->event_callback_eip) ||
                  !is_canonical_address(c.nat->syscall_callback_eip) ||
-                 !is_canonical_address(c.nat->failsafe_callback_eip) )
+                 !is_canonical_address(c.nat->failsafe_callback_eip) ||
+                 (c.nat->user_regs.rflags & (X86_EFLAGS_NT|X86_EFLAGS_VM)) )
                 return -EINVAL;
 
             fixup_guest_stack_selector(d, c.nat->user_regs.ss);
@@ -784,6 +785,9 @@ int arch_set_info_guest(
         }
         else
         {
+            if ( c.nat->user_regs.eflags & (X86_EFLAGS_NT|X86_EFLAGS_VM) )
+                return -EINVAL;
+
             fixup_guest_stack_selector(d, c.cmp->user_regs.ss);
             fixup_guest_stack_selector(d, c.cmp->kernel_ss);
             fixup_guest_code_selector(d, c.cmp->user_regs.cs);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 31.08.17 at 19:07, <[email protected]> wrote:

Luckily, this isn't a security issue, because the fix for XSA-202 (c/s 0e47f92b072) took a proactive aproach and clobbered these flags on the exit-to-guest path.

Which makes me wonder whether ...

xen/arch/x86/domain.c int arch_set_info_guest( · line 770

Quoted 10 lines
xen/arch/x86/domain.c +2 -1
@@ -765,7 +765,8 @@ int arch_set_info_guest(
                  !is_canonical_address(c.nat->gs_base_user) ||
                  !is_canonical_address(c.nat->event_callback_eip) ||
                  !is_canonical_address(c.nat->syscall_callback_eip) ||
-                 !is_canonical_address(c.nat->failsafe_callback_eip) )
+                 !is_canonical_address(c.nat->failsafe_callback_eip) ||
+                 (c.nat->user_regs.rflags & (X86_EFLAGS_NT|X86_EFLAGS_VM)) )
                 return -EINVAL;

... it is appropriate to fail the hypercall here, instead of simply clearing the bogus flags, just like we also force IF on instead of failing the operation.

xen/arch/x86/domain.c int arch_set_info_guest( · line 789

Quoted 6 lines
xen/arch/x86/domain.c +2 -0
@@ -784,6 +785,9 @@ int arch_set_info_guest(
         }
         else
         {
+            if ( c.nat->user_regs.eflags & (X86_EFLAGS_NT|X86_EFLAGS_VM) )
+                return -EINVAL;

Don't you mean c.cmp here? In fact I could see failing the request to really be the right thing for compat guests (at least for VM), while ignoring the request to set either flag for native guests (as being meaningless in 64-bit mode).

Jan

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