mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
dbd5b4a402
This implements the randomization of canary values on each build as mentioned in the comment above the STACK_CHK_GUARD macro. The canary value is generated by the buildsystem and passed to the ssp module using a `-D` compiler flag. The ssp object file, using this canary value, is marked as PHONY to make sure it is rebuild on each make invocation, thereby ensuring that each build uses a new random canary value. Implementing this properly would require generating a cryptographically secure random value on each boot of the RIOT operating system. This is not deemed possible on some constrained devices, e.g. due to lack of hardware random number generators. Besides, RIOT only seems to support a PRNG (random module) currently. While this may be implemented in the future for some devices the changes implemented in this commit may still be used as a fallback then. A hardcoded canary value is used when building software on the CI to not break the CI test cache [1]. [1]: https://github.com/RIOT-OS/RIOT/pull/13119#issuecomment-574132932
31 lines
643 B
C
31 lines
643 B
C
/*
|
|
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
* directory for more details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup sys_ssp
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief Stack Smashing Protector (SSP) helper functions
|
|
*
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
*
|
|
* @}
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "panic.h"
|
|
|
|
uintptr_t __stack_chk_guard = (uintptr_t) STACK_CHK_GUARD;
|
|
|
|
__attribute__((noreturn)) void __stack_chk_fail(void)
|
|
{
|
|
core_panic(PANIC_SSP, "ssp: stack smashing detected");
|
|
}
|