Skip to content
Commit fc152d22 authored by Mateusz Jurczyk's avatar Mateusz Jurczyk Committed by Thomas Gleixner
Browse files

x86/alternatives: Prevent uninitialized stack byte read in apply_alternatives()



In the current form of the code, if a->replacementlen is 0, the reference
to *insnbuf for comparison touches potentially garbage memory. While it
doesn't affect the execution flow due to the subsequent a->replacementlen
comparison, it is (rightly) detected as use of uninitialized memory by a
runtime instrumentation currently under my development, and could be
detected as such by other tools in the future, too (e.g. KMSAN).

Fix the "false-positive" by reordering the conditions to first check the
replacement instruction length before referencing specific opcode bytes.

Signed-off-by: default avatarMateusz Jurczyk <mjurczyk@google.com>
Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/20170524135500.27223-1-mjurczyk@google.com


Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent cbed27cd
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment