[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H4vqDGj7SMRhzKXtBL3sja_+0c5DzY8LjHS6sqvryEQWg@mail.gmail.com>
Date: Thu, 27 Nov 2025 20:43:17 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] LoongArch: Use unsigned long for _end and _text
Applied, thanks.
Huacai
On Tue, Nov 25, 2025 at 2:35 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> It is better to use unsigned long rather than long for _end and _text
> to calculate the kernel length.
>
> Cc: stable@...r.kernel.org # v6.3+
> Fixes: e5f02b51fa0c ("LoongArch: Add support for kernel address space layout randomization (KASLR)")
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> ---
> arch/loongarch/kernel/relocate.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c
> index b5e2312a2fca..76abbb8d2931 100644
> --- a/arch/loongarch/kernel/relocate.c
> +++ b/arch/loongarch/kernel/relocate.c
> @@ -183,7 +183,7 @@ static inline void __init *determine_relocation_address(void)
> if (kaslr_disabled())
> return destination;
>
> - kernel_length = (long)_end - (long)_text;
> + kernel_length = (unsigned long)_end - (unsigned long)_text;
>
> random_offset = get_random_boot() << 16;
> random_offset &= (CONFIG_RANDOMIZE_BASE_MAX_OFFSET - 1);
> @@ -232,7 +232,7 @@ unsigned long __init relocate_kernel(void)
> early_memunmap(cmdline, COMMAND_LINE_SIZE);
>
> if (random_offset) {
> - kernel_length = (long)(_end) - (long)(_text);
> + kernel_length = (unsigned long)(_end) - (unsigned long)(_text);
>
> /* Copy the kernel to it's new location */
> memcpy(location_new, _text, kernel_length);
> --
> 2.42.0
>
>
Powered by blists - more mailing lists