|
@@ -409,8 +409,13 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
|
|
|
memcpy(insnbuf, replacement, a->replacementlen);
|
|
|
insnbuf_sz = a->replacementlen;
|
|
|
|
|
|
- /* 0xe8 is a relative jump; fix the offset. */
|
|
|
- if (*insnbuf == 0xe8 && a->replacementlen == 5) {
|
|
|
+ /*
|
|
|
+ * 0xe8 is a relative jump; fix the offset.
|
|
|
+ *
|
|
|
+ * Instruction length is checked before the opcode to avoid
|
|
|
+ * accessing uninitialized bytes for zero-length replacements.
|
|
|
+ */
|
|
|
+ if (a->replacementlen == 5 && *insnbuf == 0xe8) {
|
|
|
*(s32 *)(insnbuf + 1) += replacement - instr;
|
|
|
DPRINTK("Fix CALL offset: 0x%x, CALL 0x%lx",
|
|
|
*(s32 *)(insnbuf + 1),
|