mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
powerpc64le: _init/_fini file changes for ROP
The ROP instructions were added in ISA 3.1 (ie, Power10), however they were defined so that if executed on older cpus, they would behave as nops. This allows us to emit them on older cpus and they'd just be ignored, but if run on a Power10, then the binary would be ROP protected. Hash instructions use negative offsets so the default position of ROP pointer is FRAME_ROP_SAVE from caller's SP. Modified FRAME_MIN_SIZE_PARM to 112 for ELFv2 to reserve additional 16 bytes for ROP save slot and padding. Signed-off-by: Sachin Monga <smonga@linux.ibm.com> Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
This commit is contained in:
parent
c0365d3791
commit
3051f3495c
@ -68,6 +68,9 @@ BODY_LABEL (_init):
|
|||||||
LOCALENTRY(_init)
|
LOCALENTRY(_init)
|
||||||
mflr 0
|
mflr 0
|
||||||
std 0, FRAME_LR_SAVE(r1)
|
std 0, FRAME_LR_SAVE(r1)
|
||||||
|
#ifdef __ROP_PROTECT__
|
||||||
|
hashst 0, FRAME_ROP_SAVE(r1)
|
||||||
|
#endif
|
||||||
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|
||||||
#if PREINIT_FUNCTION_WEAK
|
#if PREINIT_FUNCTION_WEAK
|
||||||
addis r9, r2, .LC0@toc@ha
|
addis r9, r2, .LC0@toc@ha
|
||||||
@ -87,4 +90,7 @@ BODY_LABEL (_fini):
|
|||||||
LOCALENTRY(_fini)
|
LOCALENTRY(_fini)
|
||||||
mflr 0
|
mflr 0
|
||||||
std 0, FRAME_LR_SAVE(r1)
|
std 0, FRAME_LR_SAVE(r1)
|
||||||
|
#ifdef __ROP_PROTECT__
|
||||||
|
hashst 0, FRAME_ROP_SAVE(r1)
|
||||||
|
#endif
|
||||||
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
|
||||||
|
@ -42,10 +42,16 @@
|
|||||||
addi r1, r1, FRAME_MIN_SIZE_PARM
|
addi r1, r1, FRAME_MIN_SIZE_PARM
|
||||||
ld r0, FRAME_LR_SAVE(r1)
|
ld r0, FRAME_LR_SAVE(r1)
|
||||||
mtlr r0
|
mtlr r0
|
||||||
|
#ifdef __ROP_PROTECT__
|
||||||
|
hashchk 0, FRAME_ROP_SAVE(r1)
|
||||||
|
#endif
|
||||||
blr
|
blr
|
||||||
|
|
||||||
.section .fini,"ax",@progbits
|
.section .fini,"ax",@progbits
|
||||||
addi r1, r1, FRAME_MIN_SIZE_PARM
|
addi r1, r1, FRAME_MIN_SIZE_PARM
|
||||||
ld r0, FRAME_LR_SAVE(r1)
|
ld r0, FRAME_LR_SAVE(r1)
|
||||||
mtlr r0
|
mtlr r0
|
||||||
|
#ifdef __ROP_PROTECT__
|
||||||
|
hashchk 0, FRAME_ROP_SAVE(r1)
|
||||||
|
#endif
|
||||||
blr
|
blr
|
||||||
|
@ -31,8 +31,9 @@
|
|||||||
#define FRAME_TOC_SAVE 40
|
#define FRAME_TOC_SAVE 40
|
||||||
#define FRAME_PARM_SAVE 48
|
#define FRAME_PARM_SAVE 48
|
||||||
#else
|
#else
|
||||||
|
#define FRAME_ROP_SAVE -8
|
||||||
#define FRAME_MIN_SIZE 32
|
#define FRAME_MIN_SIZE 32
|
||||||
#define FRAME_MIN_SIZE_PARM 96
|
#define FRAME_MIN_SIZE_PARM 112 /* Includes space for the ROP save slot */
|
||||||
#define FRAME_TOC_SAVE 24
|
#define FRAME_TOC_SAVE 24
|
||||||
#define FRAME_PARM_SAVE 32
|
#define FRAME_PARM_SAVE 32
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user