diff --git a/core/embed/bootloader/main.c b/core/embed/bootloader/main.c index 19360837f1..6b39d669ac 100644 --- a/core/embed/bootloader/main.c +++ b/core/embed/bootloader/main.c @@ -36,6 +36,20 @@ #include "messages.h" // #include "mpu.h" +/* + * Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2 + */ +#if defined(__GNUC__) && !defined(__llvm__) + +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200 +#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build" +#endif +#endif + const uint8_t BOOTLOADER_KEY_M = 2; const uint8_t BOOTLOADER_KEY_N = 3; static const uint8_t * const BOOTLOADER_KEYS[] = { diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c index 660abcdfd9..4e0909fdf8 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/firmware/main.c @@ -53,6 +53,20 @@ // from util.s extern void shutdown_privileged(void); +/* + * Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2 + */ +#if defined(__GNUC__) && !defined(__llvm__) + +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200 +#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build" +#endif +#endif + int main(void) { random_delays_init(); diff --git a/legacy/bootloader/bootloader.c b/legacy/bootloader/bootloader.c index 37785c9e9c..005e999b64 100644 --- a/legacy/bootloader/bootloader.c +++ b/legacy/bootloader/bootloader.c @@ -35,6 +35,20 @@ #include "usb.h" #include "util.h" +/* + * Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2 + */ +#if defined(__GNUC__) && !defined(__llvm__) + +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200 +#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build" +#endif +#endif + void layoutFirmwareFingerprint(const uint8_t *hash) { char str[4][17] = {0}; for (int i = 0; i < 4; i++) { diff --git a/legacy/firmware/trezor.c b/legacy/firmware/trezor.c index 02ecfbd170..831cf1edd4 100644 --- a/legacy/firmware/trezor.c +++ b/legacy/firmware/trezor.c @@ -38,6 +38,20 @@ #include "otp.h" #endif +/* + * Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2 + */ +#if defined(__GNUC__) && !defined(__llvm__) + +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200 +#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build" +#endif +#endif + /* Screen timeout */ uint32_t system_millis_lock_start = 0;