| 1 |
/* |
| 2 |
* Copyright (c) 2017, Arm Limited and Contributors. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <arch.h> |
| 8 |
#include <asm_macros.S> |
| 9 |
#include <assert_macros.S> |
| 10 |
|
| 11 |
.globl update_stack_protector_canary |
| 12 |
|
| 13 |
/* ----------------------------------------------------------------------- |
| 14 |
* void update_stack_protector_canary(void) |
| 15 |
* |
| 16 |
* Change the value of the canary used for stack smashing attacks protection. |
| 17 |
* Note: This must be called when it is safe to call C code, but this cannot be |
| 18 |
* called by C code. Doing this will make the check fail when the calling |
| 19 |
* function returns. |
| 20 |
* ----------------------------------------------------------------------- |
| 21 |
*/ |
| 22 |
|
| 23 |
func update_stack_protector_canary |
| 24 |
/* Use r4 as it is callee-saved */ |
| 25 |
mov r4, lr |
| 26 |
bl plat_get_stack_protector_canary |
| 27 |
|
| 28 |
/* Update the canary with the returned value */ |
| 29 |
ldr r1, =__stack_chk_guard |
| 30 |
str r0, [r1] |
| 31 |
bx r4 |
| 32 |
endfunc update_stack_protector_canary |
| 33 |
|
| 34 |
|