]> xenbits.xensource.com Git - xen.git/commitdiff
x86/alternatives: correct near branch check
authorJan Beulich <jbeulich@suse.com>
Fri, 27 May 2016 12:44:46 +0000 (14:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 27 May 2016 12:44:46 +0000 (14:44 +0200)
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>
master commit: cd29140ef0e65a33d62e7f5ee843077e51913f01
master date: 2016-03-09 16:51:16 +0100

xen/arch/x86/alternative.c

index 27437924c4bf7ce7915c0ad7e5be41c0a414121e..90d6f108a80906cdf6710d13cec46fdba45cd9a5 100644 (file)
@@ -175,7 +175,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,