Skip to content

Commit 560706d

Browse files
Ard Biesheuvelkees
authored andcommitted
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: Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 1c7fc5c commit 560706d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/gcc-plugins/arm_ssp_per_task_plugin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
1313
for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
1414
const char *sym;
1515
rtx body;
16-
rtx masked_sp;
16+
rtx mask, masked_sp;
1717

1818
/*
1919
* 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)
3333
* produces the address of the copy of the stack canary value
3434
* stored in struct thread_info
3535
*/
36+
mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode)));
3637
masked_sp = gen_reg_rtx(Pmode);
3738

3839
emit_insn_before(gen_rtx_SET(masked_sp,
3940
gen_rtx_AND(Pmode,
4041
stack_pointer_rtx,
41-
GEN_INT(sp_mask))),
42+
mask)),
4243
insn);
4344

4445
SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp,

0 commit comments

Comments
 (0)