[git commit] arm: clone: restore stack pointer just after return from syscall

Carmelo Amoroso carmelo.amoroso at st.com
Tue Dec 11 15:39:22 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=495c425c3b10fd9e277995fa2a379ba4a62f78bf
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

If the syscall returns with an error the stack pointer and r4 register
are not restored because the instruction 'ldmnefd sp!, {r4}' is executed
after branching to '__error' label.
This bug has been spotted out by running './utstest clone 5' from LTP
built with -fstack-protector-all compiler flag as log below:

root at cortex-a9:/usr/tests/ltp/testcases/bin# ./utstest clone 5
stack smashing detected: ./utstest terminated()

Regression introduced by commit e58798e107d652644629a1daaa95d76430808d53

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono at st.com>
Signed-off-by: Giuseppe Di Giore <giuseppe.di-giore at st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
---
 libc/sysdeps/linux/arm/clone.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S
index 33b1041..98dde22 100644
--- a/libc/sysdeps/linux/arm/clone.S
+++ b/libc/sysdeps/linux/arm/clone.S
@@ -110,8 +110,8 @@ __clone:
 	ldr	r4, [sp, #12]
 	DO_CALL (clone)
 	movs	a1, a1
-	blt	__error
 	ldmnefd	sp!, {r4}
+	blt	__error
 	IT(t, ne)
 #if defined(__USE_BX__)
 	bxne	lr


More information about the uClibc-cvs mailing list