From: Santosh Sivaraj Date: Tue, 3 Sep 2019 21:43:58 +0000 (+0530) Subject: powerpc/memcpy: Fix stack corruption for smaller sizes X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=20055a8bfaaa75f2cb9c23ecc8ab12b4abd8dc84;p=linux.git powerpc/memcpy: Fix stack corruption for smaller sizes 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 Signed-off-by: Santosh Sivaraj Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190903214359.23887-1-santosh@fossix.org --- diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S index 949976dc115dc..cb882d9a6d8a3 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