blob: a002617f193cf7ded1708f3488afdcf4a81c4a8b [file] [log] [blame]
Douglas Raillard306593d2017-02-24 18:14:15 +00001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2017, Arm Limited and Contributors. All rights reserved.
Douglas Raillard306593d2017-02-24 18:14:15 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Douglas Raillard306593d2017-02-24 18:14:15 +00005 */
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
23func update_stack_protector_canary
24 /* Use x19 as it is callee-saved */
25 mov x19, x30
26 bl plat_get_stack_protector_canary
27
28 /* Update the canary with the returned value */
29 adrp x1, __stack_chk_guard
30 str x0, [x1, #:lo12:__stack_chk_guard]
31 ret x19
32endfunc update_stack_protector_canary
33
34