stackprotector.h 648 B

12345678910111213141516171819202122232425262728
  1. #ifndef __ASM_SH_STACKPROTECTOR_H
  2. #define __ASM_SH_STACKPROTECTOR_H
  3. #include <linux/random.h>
  4. #include <linux/version.h>
  5. extern unsigned long __stack_chk_guard;
  6. /*
  7. * Initialize the stackprotector canary value.
  8. *
  9. * NOTE: this must only be called from functions that never return,
  10. * and it must always be inlined.
  11. */
  12. static __always_inline void boot_init_stack_canary(void)
  13. {
  14. unsigned long canary;
  15. /* Try to get a semi random initial value. */
  16. get_random_bytes(&canary, sizeof(canary));
  17. canary ^= LINUX_VERSION_CODE;
  18. current->stack_canary = canary;
  19. __stack_chk_guard = current->stack_canary;
  20. }
  21. #endif /* __ASM_SH_STACKPROTECTOR_H */