asm_stack_protector.S 980 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 x19 as it is callee-saved */
  21. mov x19, x30
  22. bl plat_get_stack_protector_canary
  23. /* Update the canary with the returned value */
  24. adrp x1, __stack_chk_guard
  25. str x0, [x1, #:lo12:__stack_chk_guard]
  26. ret x19
  27. endfunc update_stack_protector_canary