OSDN Git Service

Fix x86 __memset_chk.
authorLev Rumyantsev <levarum@google.com>
Sat, 30 Jul 2016 00:55:42 +0000 (17:55 -0700)
committerElliott Hughes <enh@google.com>
Mon, 1 Aug 2016 16:59:19 +0000 (09:59 -0700)
When __memset_chk_fail moved to C++, we didn't take into account
that the stack wasn't set up correctly for the jump from assembler.
Presumably no one had run the 32-bit x86 tests until now!

Bug: http://b/30513094
Change-Id: Iab9fbc731b6bfecd7ca4d3f3844d0568a5d30d86

libc/arch-x86/atom/string/sse2-memset-atom.S
libc/arch-x86/silvermont/string/sse2-memset-slm.S

index e03cd1a..04de18f 100644 (file)
@@ -117,8 +117,10 @@ ENTRY(__memset_chk)
 
   movl LEN(%esp), %ecx
   cmpl CHK_DST_LEN(%esp), %ecx
-  ja __memset_chk_fail
-  jmp L(memset_length_loaded)
+  jna L(memset_length_loaded)
+
+  POP (%ebx) // Undo ENTRANCE without returning.
+  jmp __memset_chk_fail
 END(__memset_chk)
 
        .section .text.sse2,"ax",@progbits
index f5182ba..f28e1b8 100644 (file)
@@ -117,8 +117,10 @@ ENTRY(__memset_chk)
 
   movl LEN(%esp), %ecx
   cmpl CHK_DST_LEN(%esp), %ecx
-  ja __memset_chk_fail
-  jmp L(memset_length_loaded)
+  jna L(memset_length_loaded)
+
+  POP (%ebx) // Undo ENTRANCE without returning.
+  jmp __memset_chk_fail
 END(__memset_chk)
 
        .section .text.sse2,"ax",@progbits