Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 1 | /* |
Govindraj Raja | eee28e7 | 2023-08-01 15:52:40 -0500 | [diff] [blame] | 2 | * Copyright (c) 2017, Arm Limited and Contributors. All rights reserved. |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 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 | |