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
Unified · Split
| @@ -13,7 +13,7 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) · 12 unmodified lines | ||
| 13 | 13 | for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) { |
| 14 | 14 | const char *sym; |
| 15 | 15 | rtx body; |
| 16 | − rtx masked_sp; | |
| 16 | + rtx mask, masked_sp; | |
| 17 | 17 | |
| 18 | 18 | /* |
| 19 | 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) · 13 unmodified lines | ||
| 33 | 33 | * produces the address of the copy of the stack canary value |
| 34 | 34 | * stored in struct thread_info |
| 35 | 35 | */ |
| 36 | + mask = GEN_INT(sext_hwi(sp_mask, GET_MODE_PRECISION(Pmode))); | |
| 36 | 37 | masked_sp = gen_reg_rtx(Pmode); |
| 37 | 38 | |
| 38 | 39 | emit_insn_before(gen_rtx_SET(masked_sp, |
| 39 | 40 | gen_rtx_AND(Pmode, |
| 40 | 41 | stack_pointer_rtx, |
| 41 | − GEN_INT(sp_mask))), | |
| 42 | + mask)), | |
| 42 | 43 | insn); |
| 43 | 44 | |
| 44 | 45 | SET_SRC(body) = gen_rtx_PLUS(Pmode, masked_sp, |
| @@ -52,6 +53,19 @@ static unsigned int arm_pertask_ssp_rtl_execute(void) · 7 unmodified lines | ||
| 52 | 53 | #define NO_GATE |
| 53 | 54 | #include "gcc-generate-rtl-pass.h" |
| 54 | 55 | |
| 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 | + | |
| 55 | 69 | __visible int plugin_init(struct plugin_name_args *plugin_info, |
| 56 | 70 | struct plugin_gcc_version *version) |
| 57 | 71 | { |
| @@ -99,5 +113,10 @@ __visible int plugin_init(struct plugin_name_args *plugin_info, · 41 unmodified lines | ||
| 99 | 113 | register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, |
| 100 | 114 | NULL, &arm_pertask_ssp_rtl_pass_info); |
| 101 | 115 | |
| 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 | + | |
| 102 | 121 | return 0; |
| 103 | 122 | } |