From: Andrew Morton <akpm@linux-foundation.org>
To: Coiby Xu <coxu@redhat.com>
Cc: "Breno Leitao" <leitao@debian.org>,
kexec@lists.infradead.org, "Ondrej Kozina" <okozina@redhat.com>,
"Milan Broz" <gmazyland@gmail.com>,
"Thomas Staudt" <tstaudt@de.ibm.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Kairui Song" <ryncsn@gmail.com>,
"Pingfan Liu" <kernelfans@gmail.com>,
"Baoquan He" <bhe@redhat.com>, "Dave Young" <dyoung@redhat.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
"Dave Hansen" <dave.hansen@intel.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Arnaud Lefebvre" <arnaud.lefebvre@clever-cloud.com>,
"Jan Pazdziora" <jpazdziora@redhat.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v9 1/8] kexec_file: allow to place kexec_buf randomly
Date: Mon, 25 Aug 2025 18:05:31 -0700 [thread overview]
Message-ID: <20250825180531.94bfb86a26a43127c0a1296f@linux-foundation.org> (raw)
In-Reply-To: <yng55a2z25m5upehczerzhi6zawe3j4ka7amfu4vw4cu27bbg2@x2lgbuk3iqyf>
On Mon, 25 Aug 2025 09:18:53 +0800 Coiby Xu <coxu@redhat.com> wrote:
> >diff --git a/arch/arm64/kernel/kexec_image.c b/arch/arm64/kernel/kexec_image.c
> >index 532d72ea42ee8..287b25e674d76 100644
> >--- a/arch/arm64/kernel/kexec_image.c
> >+++ b/arch/arm64/kernel/kexec_image.c
> >@@ -76,6 +76,7 @@ static void *image_load(struct kimage *image,
> > kbuf.buf_min = 0;
> > kbuf.buf_max = ULONG_MAX;
> > kbuf.top_down = false;
> >+ kbuf.random = 0;
> >
> > kbuf.buffer = kernel;
> > kbuf.bufsz = kernel_len;
> >
>
> And also thanks for posing a fix! The patch LGTM. Can you add a Fixes
> tag 'Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf
> randomly")' and then send it to kexec@lists.infradead.org? Thanks!
I turned all this into a regular patch and queued it (see below),
thanks. No additional actions are needed.
I'm really not liking that code. I laboriously verified that all
fields of kexec_buf are now initialized, except for `cma'. Is that a
bug?
This function has a call frequency of about 3x per week. Can we please
just memset the whole thing so people don't have to worry about this
any more?
From: Breno Leitao <leitao@debian.org>
Subject: kexec/arm64: initialize the random field of kbuf to zero in the image loader
Date: Thu Aug 21 04:11:21 2025 -0700
Add an explicit initialization for the random member of the kbuf structure
within the image_load function in arch/arm64/kernel/kexec_image.c.
Setting kbuf.random to zero ensures a deterministic and clean starting
state for the buffer used during kernel image loading, avoiding this UBSAN
issue later, when kbuf.random is read.
[ 32.362488] UBSAN: invalid-load in ./include/linux/kexec.h:210:10
[ 32.362649] load of value 252 is not a valid value for type '_Bool'
Link: https://lkml.kernel.org/r/oninomspajhxp4omtdapxnckxydbk2nzmrix7rggmpukpnzadw@c67o7njgdgm3
Fixes: bf454ec31add ("kexec_file: allow to place kexec_buf randomly
Signed-off-by: Breno Leitao <leitao@debian.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Coiby Xu <coxu@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: Liu Pingfan <kernelfans@gmail.com>
Cc: Milan Broz <gmazyland@gmail.com>
Cc: Ondrej Kozina <okozina@redhat.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/arm64/kernel/kexec_image.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/arm64/kernel/kexec_image.c~kexec-arm64-initialize-the-random-field-of-kbuf-to-zero-in-the-image-loader
+++ a/arch/arm64/kernel/kexec_image.c
@@ -76,6 +76,7 @@ static void *image_load(struct kimage *i
kbuf.buf_min = 0;
kbuf.buf_max = ULONG_MAX;
kbuf.top_down = false;
+ kbuf.random = 0;
kbuf.buffer = kernel;
kbuf.bufsz = kernel_len;
_
next prev parent reply other threads:[~2025-08-26 1:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 1:12 [PATCH v9 0/8] Support kdump with LUKS encryption by reusing LUKS volume keys Coiby Xu
2025-05-02 1:12 ` [PATCH v9 1/8] kexec_file: allow to place kexec_buf randomly Coiby Xu
2025-08-21 11:15 ` Breno Leitao
2025-08-25 1:18 ` Coiby Xu
2025-08-26 1:05 ` Andrew Morton [this message]
2025-08-27 11:38 ` Baoquan He
2025-08-27 13:38 ` Breno Leitao
2025-05-02 1:12 ` [PATCH v9 2/8] crash_dump: make dm crypt keys persist for the kdump kernel Coiby Xu
2025-05-02 1:12 ` [PATCH v9 3/8] crash_dump: store dm crypt keys in kdump reserved memory Coiby Xu
2025-05-02 1:12 ` [PATCH v9 4/8] crash_dump: reuse saved dm crypt keys for CPU/memory hot-plugging Coiby Xu
2025-05-02 1:12 ` [PATCH v9 5/8] crash_dump: retrieve dm crypt keys in kdump kernel Coiby Xu
2025-05-02 1:12 ` [PATCH v9 6/8] Revert "x86/mm: Remove unused __set_memory_prot()" Coiby Xu
2025-05-04 6:46 ` Andrew Morton
2025-05-07 3:05 ` Coiby Xu
2025-05-02 1:12 ` [PATCH v9 7/8] x86/crash: pass dm crypt keys to kdump kernel Coiby Xu
2025-05-02 1:12 ` [PATCH v9 8/8] x86/crash: make the page that stores the dm crypt keys inaccessible Coiby Xu
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=20250825180531.94bfb86a26a43127c0a1296f@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arnaud.lefebvre@clever-cloud.com \
--cc=berrange@redhat.com \
--cc=bhe@redhat.com \
--cc=coxu@redhat.com \
--cc=dave.hansen@intel.com \
--cc=dyoung@redhat.com \
--cc=gmazyland@gmail.com \
--cc=jpazdziora@redhat.com \
--cc=kernelfans@gmail.com \
--cc=kexec@lists.infradead.org \
--cc=leitao@debian.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=okozina@redhat.com \
--cc=ryncsn@gmail.com \
--cc=tstaudt@de.ibm.com \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®