Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Petr Vandrovec <petr@vandrovec.name>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Petr Vandrovec and committed by
Linus Torvalds
b8d3f244 3864e8cc

+3 -1
+3 -1
arch/x86_64/lib/memcpy.S
··· 124 124 .quad memcpy 125 125 .quad 1b 126 126 .byte X86_FEATURE_REP_GOOD 127 - .byte .Lfinal - memcpy 127 + /* Replace only beginning, memcpy is used to apply alternatives, so it 128 + * is silly to overwrite itself with nops - reboot is only outcome... */ 129 + .byte 2b - 1b 128 130 .byte 2b - 1b 129 131 .previous