Commit b8d3f244 authored by Petr Vandrovec's avatar Petr Vandrovec Committed by Linus Torvalds

Do not replace whole memcpy in apply alternatives

apply_alternatives uses memcpy() to apply alternatives.  Which has the
unfortunate effect that while applying memcpy alternative to memcpy
itself it tries to overwrite itself with nops - which causes #UD fault
as it overwrites half of an instruction in copy loop, and from this
point on only possible outcome is triplefault and reboot.

So let's overwrite only first two instructions of memcpy - as long as
the main memcpy loop is not in first two bytes it will work fine.
Signed-off-by: default avatarPetr Vandrovec <petr@vandrovec.name>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3864e8cc
...@@ -124,6 +124,8 @@ ENDPROC(__memcpy) ...@@ -124,6 +124,8 @@ ENDPROC(__memcpy)
.quad memcpy .quad memcpy
.quad 1b .quad 1b
.byte X86_FEATURE_REP_GOOD .byte X86_FEATURE_REP_GOOD
.byte .Lfinal - memcpy /* Replace only beginning, memcpy is used to apply alternatives, so it
* is silly to overwrite itself with nops - reboot is only outcome... */
.byte 2b - 1b
.byte 2b - 1b .byte 2b - 1b
.previous .previous
Markdown is supported
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