Skip to content

Commit dbcfc96

Browse files
committed
Merge tag 'gcc-plugins-v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull gcc-plugins fixes from Kees Cook: "Fix ARM per-task stack protector plugin under GCC 9 (Ard Biesheuvel)" * tag 'gcc-plugins-v5.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: gcc-plugins: arm_ssp_per_task_plugin: fix for GCC 9+ gcc-plugins: arm_ssp_per_task_plugin: sign extend the SP mask
2 parents 7d0ae23 + 2c88c74 commit dbcfc96

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

scripts/gcc-plugins/arm_ssp_per_task_plugin.c

Lines changed: 21 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,
@@ -52,6 +53,19 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
5253
#define NO_GATE
5354
#include "gcc-generate-rtl-pass.h"
5455

56+
#if BUILDING_GCC_VERSION >= 9000
57+
static bool no(void)
58+
{
59+
return false;
60+
}
61+
62+
static void arm_pertask_ssp_start_unit(void *gcc_data, void *user_data)
63+
{
64+
targetm.have_stack_protect_combined_set = no;
65+
targetm.have_stack_protect_combined_test = no;
66+
}
67+
#endif
68+
5569
__visible int plugin_init(struct plugin_name_args *plugin_info,
5670
struct plugin_gcc_version *version)
5771
{
@@ -99,5 +113,10 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,
99113
register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP,
100114
NULL, &arm_pertask_ssp_rtl_pass_info);
101115

116+
#if BUILDING_GCC_VERSION >= 9000
117+
register_callback(plugin_info->base_name, PLUGIN_START_UNIT,
118+
arm_pertask_ssp_start_unit, NULL);
119+
#endif
120+
102121
return 0;
103122
}

0 commit comments

Comments
 (0)