asm_stack_protector.S 949 B

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