]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: Use get_random_canary() for stack canary init
authorLuo Qiu <luoqiu@kylinsec.com.cn>
Wed, 22 Apr 2026 07:45:12 +0000 (15:45 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 22 Apr 2026 07:45:12 +0000 (15:45 +0800)
Like others, replace the custom stack canary initialization with the
get_random_canary() helper, following the pattern established in commit
622754e84b10 ("stackprotector: actually use get_random_canary()").

Signed-off-by: Luo Qiu <luoqiu@kylinsec.com.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/stackprotector.h

index a1a965751a7b98108d50da9689d99bce223993cb..42f6c3f69115b71a65db583660d70f0e87a92bbb 100644 (file)
@@ -12,9 +12,6 @@
 #ifndef _ASM_STACKPROTECTOR_H
 #define _ASM_STACKPROTECTOR_H
 
-#include <linux/random.h>
-#include <linux/version.h>
-
 extern unsigned long __stack_chk_guard;
 
 /*
@@ -25,11 +22,7 @@ extern unsigned long __stack_chk_guard;
  */
 static __always_inline void boot_init_stack_canary(void)
 {
-       unsigned long canary;
-
-       /* Try to get a semi random initial value. */
-       get_random_bytes(&canary, sizeof(canary));
-       canary ^= LINUX_VERSION_CODE;
+       unsigned long canary = get_random_canary();
 
        current->stack_canary = canary;
        __stack_chk_guard = current->stack_canary;