linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes
@ 2019-09-03 21:43 Santosh Sivaraj
  2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Santosh Sivaraj @ 2019-09-03 21:43 UTC (permalink / raw)
  To: linuxppc-dev, Michael Ellerman; +Cc: Aneesh Kumar K.V

For sizes lesser than 128 bytes, the code branches out early without saving
the stack frame, which when restored later drops frame of the caller.

Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 arch/powerpc/lib/memcpy_mcsafe_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S
index 949976dc115d..cb882d9a6d8a 100644
--- a/arch/powerpc/lib/memcpy_mcsafe_64.S
+++ b/arch/powerpc/lib/memcpy_mcsafe_64.S
@@ -84,7 +84,6 @@ err1;	stw	r0,0(r3)
 
 3:	sub	r5,r5,r6
 	cmpldi	r5,128
-	blt	5f
 
 	mflr	r0
 	stdu	r1,-STACKFRAMESIZE(r1)
@@ -99,6 +98,7 @@ err1;	stw	r0,0(r3)
 	std	r22,STK_REG(R22)(r1)
 	std	r0,STACKFRAMESIZE+16(r1)
 
+	blt	5f
 	srdi	r6,r5,7
 	mtctr	r6
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-19 10:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-03 21:43 [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Santosh Sivaraj
2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
2019-09-06 10:46 ` [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Christophe Leroy
2019-09-19 10:25 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).