From: Huacai Chen <chenhuacai@kernel.org>
To: Luo Qiu <luoqiu@kylinsec.com.cn>
Cc: WANG Xuerui <kernel@xen0n.name>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] loongarch: stackprotector: Use get_random_canary() for stack canary init
Date: Sat, 11 Apr 2026 21:12:38 +0800 [thread overview]
Message-ID: <CAAhV-H5SfXa3b--PMK8qfPkLxCbxNP_pkanwQrn6V-bqy8=o5Q@mail.gmail.com> (raw)
In-Reply-To: <599CB656808E9EE5+20260409073356.1476812-1-luoqiu@kylinsec.com.cn>
Applied, thanks.
Huacai
On Thu, Apr 9, 2026 at 3:35 PM Luo Qiu <luoqiu@kylinsec.com.cn> wrote:
>
> 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>
> ---
> arch/loongarch/include/asm/stackprotector.h | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/arch/loongarch/include/asm/stackprotector.h b/arch/loongarch/include/asm/stackprotector.h
> index a1a965751a7b..42f6c3f69115 100644
> --- a/arch/loongarch/include/asm/stackprotector.h
> +++ b/arch/loongarch/include/asm/stackprotector.h
> @@ -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;
> --
> 2.53.0
>
prev parent reply other threads:[~2026-04-11 13:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 7:33 [PATCH] loongarch: stackprotector: Use get_random_canary() for stack canary init Luo Qiu
2026-04-11 13:12 ` Huacai Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAhV-H5SfXa3b--PMK8qfPkLxCbxNP_pkanwQrn6V-bqy8=o5Q@mail.gmail.com' \
--to=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=luoqiu@kylinsec.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).