aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2019-01-18 05:58:06 -0500
committerKees Cook <keescook@chromium.org>2019-01-20 17:06:40 -0500
commit560706d5d2589ef510f5436d69ab510a351b8cf7 (patch)
treeaaf4685dbe212ad2e0b996308905a1cd16ffdf29 /scripts/gcc-plugins
parent1c7fc5cbc33980acd13d668f1c8f0313d6ae9fd8 (diff)
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>
Diffstat (limited to 'scripts/gcc-plugins')
-rw-r--r--scripts/gcc-plugins/arm_ssp_per_task_plugin.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c
index de70b8470971..a65fbefb8501 100644
--- a/scripts/gcc-plugins/arm_ssp_per_task_plugin.c
+++ b/scripts/gcc-plugins/arm_ssp_per_task_plugin.c
@@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
13 for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { 13 for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
14 const char *sym; 14 const char *sym;
15 rtx body; 15 rtx body;
16 rtx masked_sp; 16 rtx mask, masked_sp;
17 17
18 /* 18 /*
19 * Find a SET insn involving a SYMBOL_REF to __stack_chk_guard 19 * 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 * produces the address of the copy of the stack canary value 33 * produces the address of the copy of the stack canary value
34 * stored in struct thread_info 34 * stored in struct thread_info
35 */ 35 */
36 mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode)));
36 masked_sp = gen_reg_rtx(Pmode); 37 masked_sp = gen_reg_rtx(Pmode);
37 38
38 emit_insn_before(gen_rtx_SET(masked_sp, 39 emit_insn_before(gen_rtx_SET(masked_sp,
39 gen_rtx_AND(Pmode, 40 gen_rtx_AND(Pmode,
40 stack_pointer_rtx, 41 stack_pointer_rtx,
41 GEN_INT(sp_mask))), 42 mask)),
42 insn); 43 insn);
43 44
44 SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp, 45 SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp,