From nobody Mon Dec 1 21:30:54 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6974524886A for ; Thu, 27 Nov 2025 18:26:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764268012; cv=none; b=gValOBILVq0h7ubuvOIfTGvcdk/ROABsLyC+9a7+B3qFAwZP23WO6cI+JPDQwWLq7adVMYu+yiPwtYcZFIKpWmbdKr5gjdbUJ4VkgIQuBJbq6E4k6SW7dlg1F9OQ7SMv/AvlhcH62Q5r38eMnu9lWOwrLt9qJCbK8Y9l/c1Lb5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764268012; c=relaxed/simple; bh=3vFySqutaCqN+2QPZpUiCdk2YEz62CLsrhPCF7R8F64=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PigTd/h99tfu20n94tUqIZYBBObOUSIfxVyggCw6Z5foZOPK1w+paOhIxYXgjfWuaUuwmwmuYS9CTgB5nw1RUrvCXNhrQhTNvI6dWJjW667oGtUBxn2uI14M3+aMrmFSrIAhgxJfrlI+f6YE0fIy1XdkYNu7iTlynq3WQtbzSvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F0F0C176A; Thu, 27 Nov 2025 10:26:41 -0800 (PST) Received: from e129823.cambridge.arm.com (e129823.arm.com [10.1.197.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0B5DE3F73B; Thu, 27 Nov 2025 10:26:47 -0800 (PST) From: Yeoreum Yun To: catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, bhe@redhat.com, leitao@debian.org, coxu@redhat.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yeoreum Yun Subject: [PATCH] arm64: kernel: initialize missing kexec_buf->random field Date: Thu, 27 Nov 2025 18:26:44 +0000 Message-Id: <20251127182644.1577592-1-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 '_B= ool') [ +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/20= 15 [ +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") Signed-off-by: Yeoreum Yun --- arch/arm64/kernel/kexec_image.c | 3 +++ arch/arm64/kernel/machine_kexec_file.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_imag= e.c index 532d72ea42ee..db6fb8c599a1 100644 --- a/arch/arm64/kernel/kexec_image.c +++ b/arch/arm64/kernel/kexec_image.c @@ -76,6 +76,9 @@ static void *image_load(struct kimage *image, kbuf.buf_min =3D 0; kbuf.buf_max =3D ULONG_MAX; kbuf.top_down =3D false; +#ifdef CONFIG_CRASH_DUMP + kbuf.random =3D false; +#endif kbuf.buffer =3D kernel; kbuf.bufsz =3D kernel_len; diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/mac= hine_kexec_file.c index 410060ebd86d..06f38866424a 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -94,7 +94,11 @@ int load_other_segments(struct kimage *image, char *initrd, unsigned long initrd_len, char *cmdline) { - struct kexec_buf kbuf =3D {}; + struct kexec_buf kbuf =3D { +#ifdef CONFIG_CRASH_DUMP + .random =3D false, +#endif + }; void *dtb =3D NULL; unsigned long initrd_load_addr =3D 0, dtb_len, orig_segments =3D image->nr_segments; -- LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}