aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorSachin Monga <smonga@linux.ibm.com>2024-12-09 16:47:40 -0500
committerPeter Bergner <bergner@linux.ibm.com>2024-12-09 16:49:54 -0500
commitbe13e467641cda4bd147ef3ef3afe9e4c6a35e1d (patch)
treefae84951f8050b152386818ed2c69c6040ceb6b3 /sysdeps
parent9e08698e4caec73a83be1bf22074b58b59c2cb18 (diff)
downloadglibc-be13e467641cda4bd147ef3ef3afe9e4c6a35e1d.zip
glibc-be13e467641cda4bd147ef3ef3afe9e4c6a35e1d.tar.gz
glibc-be13e467641cda4bd147ef3ef3afe9e4c6a35e1d.tar.bz2
powerpc64le: ROP changes for the *context and setjmp functions
Add ROP protection for the getcontext, setcontext, makecontext, swapcontext and __sigsetjmp_symbol functions. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/powerpc/powerpc64/setjmp-common.S6
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/getcontext.S12
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S6
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S24
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S24
5 files changed, 60 insertions, 12 deletions
diff --git a/sysdeps/powerpc/powerpc64/setjmp-common.S b/sysdeps/powerpc/powerpc64/setjmp-common.S
index d677741..920621b 100644
--- a/sysdeps/powerpc/powerpc64/setjmp-common.S
+++ b/sysdeps/powerpc/powerpc64/setjmp-common.S
@@ -224,6 +224,9 @@ L(no_vmx):
#else
mflr r0
std r0,FRAME_LR_SAVE(r1)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
stdu r1,-FRAME_MIN_SIZE(r1)
cfi_adjust_cfa_offset(FRAME_MIN_SIZE)
cfi_offset(lr,FRAME_LR_SAVE)
@@ -232,6 +235,9 @@ L(no_vmx):
ld r0,FRAME_MIN_SIZE+FRAME_LR_SAVE(r1)
addi r1,r1,FRAME_MIN_SIZE
mtlr r0
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
blr
#endif
END (__sigsetjmp_symbol)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getcontext.S
index 96d6005..02d3599 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/getcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/getcontext.S
@@ -32,6 +32,9 @@ ENTRY(__novec_getcontext)
std r0,(SIGCONTEXT_GP_REGS+(PT_R0*8))(r3)
std r1,(SIGCONTEXT_GP_REGS+(PT_R1*8))(r3)
mflr r0
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r2,(SIGCONTEXT_GP_REGS+(PT_R2*8))(r3)
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
@@ -139,6 +142,9 @@ ENTRY(__novec_getcontext)
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
blr
PSEUDO_END(__novec_getcontext)
@@ -161,6 +167,9 @@ ENTRY(__getcontext)
std r0,(SIGCONTEXT_GP_REGS+(PT_R0*8))(r3)
std r1,(SIGCONTEXT_GP_REGS+(PT_R1*8))(r3)
mflr r0
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r2,(SIGCONTEXT_GP_REGS+(PT_R2*8))(r3)
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
@@ -377,6 +386,9 @@ L(has_no_vec):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
blr
PSEUDO_END(__getcontext)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
index 97ea557..f959591 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S
@@ -39,6 +39,9 @@ ENTRY (__makecontext)
addi r6,r1,FRAME_PARM_SAVE+24
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
stdu r1,-128(r1)
cfi_adjust_cfa_offset (128)
@@ -181,6 +184,9 @@ L(gotexitcodeaddr):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
blr
END(__makecontext)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S
index eb83d21..1dcb138 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S
@@ -38,8 +38,11 @@
ENTRY(__novec_setcontext)
CALL_MCOUNT 1
mflr r0
- std r31,-8(1)
- cfi_offset(r31,-8)
+ std r31,-16(1)
+ cfi_offset(r31,-16)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
stdu r1,-128(r1)
@@ -184,7 +187,10 @@ L(nv_error_exit):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
- ld r31,-8(r1)
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
+ ld r31,-16(r1)
blr
PSEUDO_END(__novec_setcontext)
@@ -197,8 +203,11 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3)
ENTRY(__setcontext)
CALL_MCOUNT 1
mflr r0
- std r31,-8(1)
- cfi_offset(r31,-8)
+ std r31,-16(1)
+ cfi_offset(r31,-16)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
stdu r1,-128(r1)
@@ -446,7 +455,10 @@ L(error_exit):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
- ld r31,-8(r1)
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
+ ld r31,-16(r1)
blr
PSEUDO_END(__setcontext)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S
index b7133f0..5d62182 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S
@@ -40,8 +40,11 @@ ENTRY(__novec_swapcontext)
std r0,(SIGCONTEXT_GP_REGS+(PT_R0*8))(r3)
std r1,(SIGCONTEXT_GP_REGS+(PT_R1*8))(r3)
mflr r0
- std r31,-8(1)
- cfi_offset(r31,-8)
+ std r31,-16(1)
+ cfi_offset(r31,-16)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r2,(SIGCONTEXT_GP_REGS+(PT_R2*8))(r3)
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
@@ -271,7 +274,10 @@ L(nv_error_exit):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
- ld r31,-8(r1)
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
+ ld r31,-16(r1)
blr
PSEUDO_END(__novec_swapcontext)
@@ -287,8 +293,11 @@ ENTRY(__swapcontext)
std r0,(SIGCONTEXT_GP_REGS+(PT_R0*8))(r3)
std r1,(SIGCONTEXT_GP_REGS+(PT_R1*8))(r3)
mflr r0
- std r31,-8(1)
- cfi_offset(r31,-8)
+ std r31,-16(1)
+ cfi_offset(r31,-16)
+#ifdef __ROP_PROTECT__
+ hashst r0,FRAME_ROP_SAVE(r1)
+#endif
std r2,(SIGCONTEXT_GP_REGS+(PT_R2*8))(r3)
std r0,FRAME_LR_SAVE(r1)
cfi_offset (lr, FRAME_LR_SAVE)
@@ -731,7 +740,10 @@ L(error_exit):
ld r0,128+FRAME_LR_SAVE(r1)
addi r1,r1,128
mtlr r0
- ld r31,-8(r1)
+#ifdef __ROP_PROTECT__
+ hashchk r0,FRAME_ROP_SAVE(r1)
+#endif
+ ld r31,-16(r1)
blr
PSEUDO_END(__swapcontext)