Skip to content

Commit 2c88c74

Browse files
Ard Biesheuvelkees
authored andcommitted
gcc-plugins: arm_ssp_per_task_plugin: fix for GCC 9+
GCC 9 reworks the way the references to the stack canary are emitted, to prevent the value from being spilled to the stack before the final comparison in the epilogue, defeating the purpose, given that the spill slot is under control of the attacker that we are protecting ourselves from. Since our canary value address is obtained without accessing memory (as opposed to pre-v7 code that will obtain it from a literal pool), it is unlikely (although not guaranteed) that the compiler will spill the canary value in the same way, so let's just disable this improvement when building with GCC9+. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 560706d commit 2c88c74

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/gcc-plugins/arm_ssp_per_task_plugin.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ static unsigned int arm_pertask_ssp_rtl_execute(void)
5353
#define NO_GATE
5454
#include "gcc-generate-rtl-pass.h"
5555

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+
5669
__visible int plugin_init(struct plugin_name_args *plugin_info,
5770
struct plugin_gcc_version *version)
5871
{
@@ -100,5 +113,10 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,
100113
register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP,
101114
NULL, &arm_pertask_ssp_rtl_pass_info);
102115

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+
103121
return 0;
104122
}

0 commit comments

Comments
 (0)