Commit 560706d5 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Kees Cook

gcc-plugins: arm_ssp_per_task_plugin: sign extend the SP mask

The ARM per-task stack protector GCC plugin hits an assert in
the compiler in some case, due to the fact the the SP mask
expression is not sign-extended as it should be. So fix that.
Suggested-by: default avatarKugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 1c7fc5cb
...@@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) ...@@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
const char *sym; const char *sym;
rtx body; rtx body;
rtx masked_sp; rtx mask, masked_sp;
/* /*
* Find a SET insn involving a SYMBOL_REF to __stack_chk_guard * Find a SET insn involving a SYMBOL_REF to __stack_chk_guard
...@@ -33,12 +33,13 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) ...@@ -33,12 +33,13 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
* produces the address of the copy of the stack canary value * produces the address of the copy of the stack canary value
* stored in struct thread_info * stored in struct thread_info
*/ */
mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode)));
masked_sp = gen_reg_rtx(Pmode); masked_sp = gen_reg_rtx(Pmode);
emit_insn_before(gen_rtx_SET(masked_sp, emit_insn_before(gen_rtx_SET(masked_sp,
gen_rtx_AND(Pmode, gen_rtx_AND(Pmode,
stack_pointer_rtx, stack_pointer_rtx,
GEN_INT(sp_mask))), mask)),
insn); insn);
SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp, SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment