]> xenbits.xensource.com Git - xen.git/commitdiff
x86emul: always fill x86_insn_modrm()'s outputs
authorJan Beulich <jbeulich@suse.com>
Wed, 19 Apr 2017 11:25:44 +0000 (13:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 19 Apr 2017 11:25:44 +0000 (13:25 +0200)
The function is rather unlikely to be called for insns which don't have
ModRM bytes, and hence addressing Coverity's recurring complaint of
callers potentially consuming uninitialized data when they know that
certain opcodes have ModRM bytes can be suppressed this way without
unduly adding overhead to fast paths.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/x86_emulate/x86_emulate.c

index 6f1076148ee4d875f9e2bf9a5b6af9bc669786b5..c822221d8a24a92bdb0bf06a5a7731f8e9b9eaf4 100644 (file)
@@ -8017,8 +8017,14 @@ x86_insn_modrm(const struct x86_emulate_state *state,
 {
     check_state(state);
 
-    if ( state->modrm_mod > 3 )
+    if ( unlikely(state->modrm_mod > 3) )
+    {
+        if ( rm )
+            *rm = ~0U;
+        if ( reg )
+            *reg = ~0U;
         return -EINVAL;
+    }
 
     if ( rm )
         *rm = state->modrm_rm;