From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0459C8303F for ; Tue, 26 Aug 2025 01:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:Mime-Version:References:In-Reply-To:Message-Id:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uflk8J63v5Vdk+A5T71w43msAplrhyNBzSbyCutgOBw=; b=RfKrnFxfqkX2ERLkhN/NtGLuPX o7fvGSKQPVKoQPLWPSeRVofXdpFoJ4AsuJJ5kRcxxSTFcl7F3KFLJgB37GGxW9U8yuS7wvePUFBGN /PgBVtel9e9N3v6OXzX4jqy/GHB9bL2wKwTMmF7nLW0ma4Q+dPYFTukORipifjxi9k7CT11tIXQdr oAwdvxc7WKv7YuOPpConhbOfDDLBbXO6p4zD4HeEcX1EblpxoOStqr4rCPzqYXZY6nLNWPOC4hINo zh8jgiKMIK+72S2O9jXlKM8IIz7KLIPRdfrsVGyPibuR920q4jKB7+PHipAwnZMN3INjY5QWBgBxL qaeSeofg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqiAf-0000000AFe8-3kwZ; Tue, 26 Aug 2025 01:08:21 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uqi7x-0000000AFPK-1ZPd; Tue, 26 Aug 2025 01:05:34 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 9A4F7406A6; Tue, 26 Aug 2025 01:05:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1935C4CEED; Tue, 26 Aug 2025 01:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1756170332; bh=9t+LpWoHJIsYPbMjiU2USC8E5Wcpyq+n6+4DJhGHFvo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y8XBmyN0f/0MgGjeKimTUShtaB8EhLKUUrrmRMR3IbngvR7S1rg8rHkhnN78HfAhX DkF1xazVTsIy6tOSICzsHTiycb3Y3thNj93LolbqqMl4AQS5gOJlcJyEdyCIp+1zxZ rCJn2sE5Sff8NjTQL5EKgcgv+i4W35W228YHKaoo= Date: Mon, 25 Aug 2025 18:05:31 -0700 From: Andrew Morton To: Coiby Xu Cc: Breno Leitao , kexec@lists.infradead.org, Ondrej Kozina , Milan Broz , Thomas Staudt , Daniel P . =?ISO-8859-1?Q?Berrang=E9?= , Kairui Song , Pingfan Liu , Baoquan He , Dave Young , linux-kernel@vger.kernel.org, x86@kernel.org, Dave Hansen , Vitaly Kuznetsov , Arnaud Lefebvre , Jan Pazdziora , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v9 1/8] kexec_file: allow to place kexec_buf randomly Message-Id: <20250825180531.94bfb86a26a43127c0a1296f@linux-foundation.org> In-Reply-To: References: <20250502011246.99238-1-coxu@redhat.com> <20250502011246.99238-2-coxu@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250825_180533_458004_3D0C3B61 X-CRM114-Status: GOOD ( 16.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 25 Aug 2025 09:18:53 +0800 Coiby Xu 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 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 Cc: Baoquan He Cc: Coiby Xu Cc: "Daniel P. Berrange" Cc: Dave Hansen Cc: Dave Young Cc: Kairui Song Cc: Liu Pingfan Cc: Milan Broz Cc: Ondrej Kozina Cc: Vitaly Kuznetsov Cc: Signed-off-by: Andrew Morton --- 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; _