]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
x86/alternatives: correct near branch check
authorJan Beulich <jbeulich@suse.com>
Wed, 9 Mar 2016 15:51:16 +0000 (16:51 +0100)
committerWei Liu <wei.liu2@citrix.com>
Tue, 15 Mar 2016 16:32:34 +0000 (16:32 +0000)
Make sure the near JMP/CALL check doesn't consume uninitialized
data, not even in a benign way. And relax the length check at once.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/alternative.c

index 0a0ce156e7a7463ded4b36c6cd7fc3b3ecb84ba0..26ad2b935f45f61d48b5fe23509044668db892b0 100644 (file)
@@ -178,7 +178,7 @@ static void __init apply_alternatives(struct alt_instr *start, struct alt_instr
         memcpy(insnbuf, replacement, a->replacementlen);
 
         /* 0xe8/0xe9 are relative branches; fix the offset. */
-        if ( (*insnbuf & 0xfe) == 0xe8 && a->replacementlen == 5 )
+        if ( a->replacementlen >= 5 && (*insnbuf & 0xfe) == 0xe8 )
             *(s32 *)(insnbuf + 1) += replacement - instr;
 
         add_nops(insnbuf + a->replacementlen,