From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18652149C7B for ; Fri, 28 Nov 2025 00:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764289056; cv=none; b=MzZcApuSQF+tJ9VrfSqZMvb2q3cybj2Mfz2z2yaUp+xCYL3S0/SfMEAJqPHbl+Bcs5+4dAbUT2pKv19eb9mo0AlUNz9+P83ICgwV+4WxWO2n61gQZktIiWhB12FFXTAntHGLcPLDZz6Sm2cIq3ojrvAraXfO4otqbZSR2nQ59qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764289056; c=relaxed/simple; bh=SkxrKc6Wox8TWfrRXKVFlCupB66AyJgH59+iG0G7Iy8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YfvoHTHWXDHtbA0Dr1yrx0KUPHEc5l0xLhjNjJQPnrlXqKUzojtvJp1GaLKqf8du2I0KLT2DQ4ETmDCwIcvsqaGorxleUZ92PxLtE3tP7YxqqwLZWM1tTHHbFtLNWpKjWagefKxPO2F0mo/kP+Xwfb2Qvkoevil5b9K8lUdR/2g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iyWLuJfm; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iyWLuJfm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764289054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7YdZPHc9UU1cTih+a9P92g90bZFsf3CbSrAZ21e8g1I=; b=iyWLuJfmoZLXefy/zs98dy3iom1LY0MSvPfrEFwlAEtJ2FH5rHcj8bW9JVyQt9P71Q5w7H Gl2d8t0fh1sU4yyqDJ0vBvzH5B9DU4gyucxzCLBplNvW4AA1h94JykW/by/5oiXacB1Xqz CLq7GzHJVLq3vrHwAWE+AL6euEpB19c= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-eQairQOcPdOBxcV4pnA9cw-1; Thu, 27 Nov 2025 19:17:29 -0500 X-MC-Unique: eQairQOcPdOBxcV4pnA9cw-1 X-Mimecast-MFC-AGG-ID: eQairQOcPdOBxcV4pnA9cw_1764289048 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 902C31956050; Fri, 28 Nov 2025 00:17:27 +0000 (UTC) Received: from localhost (unknown [10.72.112.7]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AABB3180047F; Fri, 28 Nov 2025 00:17:25 +0000 (UTC) Date: Fri, 28 Nov 2025 08:17:21 +0800 From: Baoquan He To: Andrew Morton , pjw@kernel.org, leitao@debian.org Cc: Yeoreum Yun , catalin.marinas@arm.com, will@kernel.org, leitao@debian.org, coxu@redhat.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: kernel: initialize missing kexec_buf->random field Message-ID: References: <20251127182644.1577592-1-yeoreum.yun@arm.com> <20251127113706.d89a84f277dab3ad273dde75@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251127113706.d89a84f277dab3ad273dde75@linux-foundation.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 On 11/27/25 at 11:37am, Andrew Morton wrote: > On Thu, 27 Nov 2025 18:26:44 +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") > > Thanks, I'll add a cc:stable to this. This has been fixed in below series from Breno Leitao. [PATCH 0/3] kexec: Fix invalid field access https://lore.kernel.org/all/20250827-kbuf_all-v1-0-1df9882bb01a@debian.org/T/#u And Paul Walmsley said he has merged the series to riscv/linux.git. While I can only see the patch for risc-v. The other two are missing. 95c54cd9c769 riscv: kexec: Initialize kexec_buf struct