aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPetr Vandrovec <petr@vandrovec.name>2007-08-12 04:12:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-12 04:42:37 -0400
commitb8d3f2448b8f4ba24f301e23585547ba1acc1f04 (patch)
treed3b01b918c779bbce433e753c3fb0207390c4950 /arch
parent3864e8ccbba1dcdea87398ab80fdc8ae0fab7c45 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/lib/memcpy.S4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86_64/lib/memcpy.S b/arch/x86_64/lib/memcpy.S
index 0ea0ddc875a7..c22981fa2f3a 100644
--- a/arch/x86_64/lib/memcpy.S
+++ b/arch/x86_64/lib/memcpy.S
@@ -124,6 +124,8 @@ ENDPROC(__memcpy)
124 .quad memcpy 124 .quad memcpy
125 .quad 1b 125 .quad 1b
126 .byte X86_FEATURE_REP_GOOD 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 .byte 2b - 1b 130 .byte 2b - 1b
129 .previous 131 .previous