* [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field
@ 2025-12-01 10:51 Yeoreum Yun
2025-12-01 11:41 ` Breno Leitao
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yeoreum Yun @ 2025-12-01 10:51 UTC (permalink / raw)
To: akpm, pjw, leitao, catalin.marinas, will, mark.rutland, coxu
Cc: linux-arm-kernel, linux-kernel, Yeoreum Yun, stable
Commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
introduced the kexec_buf->random field to enable random placement of
kexec_buf.
However, this field was never properly initialized for kexec images
that do not need to be placed randomly, leading to the following UBSAN
warning:
[ +0.364528] ------------[ cut here ]------------
[ +0.000019] UBSAN: invalid-load in ./include/linux/kexec.h:210:12
[ +0.000131] load of value 2 is not a valid value for type 'bool' (aka '_Bool')
[ +0.000003] CPU: 4 UID: 0 PID: 927 Comm: kexec Not tainted 6.18.0-rc7+ #3 PREEMPT(full)
[ +0.000002] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
[ +0.000000] Call trace:
[ +0.000001] show_stack+0x24/0x40 (C)
[ +0.000006] __dump_stack+0x28/0x48
[ +0.000002] dump_stack_lvl+0x7c/0xb0
[ +0.000002] dump_stack+0x18/0x34
[ +0.000001] ubsan_epilogue+0x10/0x50
[ +0.000002] __ubsan_handle_load_invalid_value+0xc8/0xd0
[ +0.000003] locate_mem_hole_callback+0x28c/0x2a0
[ +0.000003] kexec_locate_mem_hole+0xf4/0x2f0
[ +0.000001] kexec_add_buffer+0xa8/0x178
[ +0.000002] image_load+0xf0/0x258
[ +0.000001] __arm64_sys_kexec_file_load+0x510/0x718
[ +0.000002] invoke_syscall+0x68/0xe8
[ +0.000001] el0_svc_common+0xb0/0xf8
[ +0.000002] do_el0_svc+0x28/0x48
[ +0.000001] el0_svc+0x40/0xe8
[ +0.000002] el0t_64_sync_handler+0x84/0x140
[ +0.000002] el0t_64_sync+0x1bc/0x1c0
To address this, initialise kexec_buf->random field properly.
Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
Suggested-by: Breno Leitao <leitao@debian.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
arch/arm64/kernel/kexec_image.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c
index 532d72ea42ee..b70f4df15a1a 100644
--- a/arch/arm64/kernel/kexec_image.c
+++ b/arch/arm64/kernel/kexec_image.c
@@ -41,7 +41,7 @@ static void *image_load(struct kimage *image,
struct arm64_image_header *h;
u64 flags, value;
bool be_image, be_kernel;
- struct kexec_buf kbuf;
+ struct kexec_buf kbuf = {};
unsigned long text_offset, kernel_segment_number;
struct kexec_segment *kernel_segment;
int ret;
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field
2025-12-01 10:51 [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field Yeoreum Yun
@ 2025-12-01 11:41 ` Breno Leitao
2026-01-02 19:03 ` Yeoreum Yun
2026-01-05 22:58 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Breno Leitao @ 2025-12-01 11:41 UTC (permalink / raw)
To: Yeoreum Yun
Cc: akpm, pjw, catalin.marinas, will, mark.rutland, coxu,
linux-arm-kernel, linux-kernel, stable
On Mon, Dec 01, 2025 at 10:51:18AM +0000, Yeoreum Yun wrote:
> Commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
> introduced the kexec_buf->random field to enable random placement of
> kexec_buf.
>
> However, this field was never properly initialized for kexec images
> that do not need to be placed randomly, leading to the following UBSAN
> warning:
>
> [ +0.364528] ------------[ cut here ]------------
> [ +0.000019] UBSAN: invalid-load in ./include/linux/kexec.h:210:12
> [ +0.000131] load of value 2 is not a valid value for type 'bool' (aka '_Bool')
> [ +0.000003] CPU: 4 UID: 0 PID: 927 Comm: kexec Not tainted 6.18.0-rc7+ #3 PREEMPT(full)
> [ +0.000002] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
> [ +0.000000] Call trace:
> [ +0.000001] show_stack+0x24/0x40 (C)
> [ +0.000006] __dump_stack+0x28/0x48
> [ +0.000002] dump_stack_lvl+0x7c/0xb0
> [ +0.000002] dump_stack+0x18/0x34
> [ +0.000001] ubsan_epilogue+0x10/0x50
> [ +0.000002] __ubsan_handle_load_invalid_value+0xc8/0xd0
> [ +0.000003] locate_mem_hole_callback+0x28c/0x2a0
> [ +0.000003] kexec_locate_mem_hole+0xf4/0x2f0
> [ +0.000001] kexec_add_buffer+0xa8/0x178
> [ +0.000002] image_load+0xf0/0x258
> [ +0.000001] __arm64_sys_kexec_file_load+0x510/0x718
> [ +0.000002] invoke_syscall+0x68/0xe8
> [ +0.000001] el0_svc_common+0xb0/0xf8
> [ +0.000002] do_el0_svc+0x28/0x48
> [ +0.000001] el0_svc+0x40/0xe8
> [ +0.000002] el0t_64_sync_handler+0x84/0x140
> [ +0.000002] el0t_64_sync+0x1bc/0x1c0
>
> To address this, initialise kexec_buf->random field properly.
>
> Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
> Suggested-by: Breno Leitao <leitao@debian.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
Thanks for the fix,
--breno
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field
2025-12-01 10:51 [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field Yeoreum Yun
2025-12-01 11:41 ` Breno Leitao
@ 2026-01-02 19:03 ` Yeoreum Yun
2026-01-05 22:58 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Yeoreum Yun @ 2026-01-02 19:03 UTC (permalink / raw)
To: akpm, pjw, leitao, catalin.marinas, will, mark.rutland, coxu
Cc: linux-arm-kernel, linux-kernel, stable
Gentle ping in case of forgotten.
On Mon, Dec 01, 2025 at 10:51:18AM +0000, Yeoreum Yun wrote:
> Commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
> introduced the kexec_buf->random field to enable random placement of
> kexec_buf.
>
> However, this field was never properly initialized for kexec images
> that do not need to be placed randomly, leading to the following UBSAN
> warning:
>
> [ +0.364528] ------------[ cut here ]------------
> [ +0.000019] UBSAN: invalid-load in ./include/linux/kexec.h:210:12
> [ +0.000131] load of value 2 is not a valid value for type 'bool' (aka '_Bool')
> [ +0.000003] CPU: 4 UID: 0 PID: 927 Comm: kexec Not tainted 6.18.0-rc7+ #3 PREEMPT(full)
> [ +0.000002] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
> [ +0.000000] Call trace:
> [ +0.000001] show_stack+0x24/0x40 (C)
> [ +0.000006] __dump_stack+0x28/0x48
> [ +0.000002] dump_stack_lvl+0x7c/0xb0
> [ +0.000002] dump_stack+0x18/0x34
> [ +0.000001] ubsan_epilogue+0x10/0x50
> [ +0.000002] __ubsan_handle_load_invalid_value+0xc8/0xd0
> [ +0.000003] locate_mem_hole_callback+0x28c/0x2a0
> [ +0.000003] kexec_locate_mem_hole+0xf4/0x2f0
> [ +0.000001] kexec_add_buffer+0xa8/0x178
> [ +0.000002] image_load+0xf0/0x258
> [ +0.000001] __arm64_sys_kexec_file_load+0x510/0x718
> [ +0.000002] invoke_syscall+0x68/0xe8
> [ +0.000001] el0_svc_common+0xb0/0xf8
> [ +0.000002] do_el0_svc+0x28/0x48
> [ +0.000001] el0_svc+0x40/0xe8
> [ +0.000002] el0t_64_sync_handler+0x84/0x140
> [ +0.000002] el0t_64_sync+0x1bc/0x1c0
>
> To address this, initialise kexec_buf->random field properly.
>
> Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
> Suggested-by: Breno Leitao <leitao@debian.org>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> ---
> arch/arm64/kernel/kexec_image.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c
> index 532d72ea42ee..b70f4df15a1a 100644
> --- a/arch/arm64/kernel/kexec_image.c
> +++ b/arch/arm64/kernel/kexec_image.c
> @@ -41,7 +41,7 @@ static void *image_load(struct kimage *image,
> struct arm64_image_header *h;
> u64 flags, value;
> bool be_image, be_kernel;
> - struct kexec_buf kbuf;
> + struct kexec_buf kbuf = {};
> unsigned long text_offset, kernel_segment_number;
> struct kexec_segment *kernel_segment;
> int ret;
> --
> LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
>
--
Sincerely,
Yeoreum Yun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field
2025-12-01 10:51 [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field Yeoreum Yun
2025-12-01 11:41 ` Breno Leitao
2026-01-02 19:03 ` Yeoreum Yun
@ 2026-01-05 22:58 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2026-01-05 22:58 UTC (permalink / raw)
To: akpm, pjw, leitao, catalin.marinas, mark.rutland, coxu, Yeoreum Yun
Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kernel, stable
On Mon, 01 Dec 2025 10:51:18 +0000, Yeoreum Yun wrote:
> Commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly")
> introduced the kexec_buf->random field to enable random placement of
> kexec_buf.
>
> However, this field was never properly initialized for kexec images
> that do not need to be placed randomly, leading to the following UBSAN
> warning:
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64: kernel: initialize missing kexec_buf->random field
https://git.kernel.org/arm64/c/15dd20dda979
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-05 22:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 10:51 [PATCH v2] arm64: kernel: initialize missing kexec_buf->random field Yeoreum Yun
2025-12-01 11:41 ` Breno Leitao
2026-01-02 19:03 ` Yeoreum Yun
2026-01-05 22:58 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®