From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DFB08153BE9 for ; Tue, 27 Jan 2026 07:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769498709; cv=none; b=mgdzZv6pV3hZqyekE2NkuFiX//vHQ0IggKJYX5Ma46p76iOsCQET9bLU2PyM/pXquPoH0ExsFK3Ohp725iSAGeiuHB/kw5Bk9ShacaoymTDRViimsYyXOPMnwbeihYCsb3pyifK5Ng0X7T1p8T9ib6l8DMGtRg0tw22hHj4YHd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769498709; c=relaxed/simple; bh=NM/XyGcuu3oC40AjWHvNWgcayap1TyIPrLlqNMwrM1k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kTB4mm/TbOa+aR6iAZ0EUTUHEngwAukLmIV1L2jNnJtPdfXrbozTZ3GlXXl4gbpKiZhWD8Z0FLqoJfmKExyur5FKjN5Kuq494R4iHhFbz5FsXag+sqP9TZ43JSFV8y3haBB5GGxlmsCvF+qNdC/I3iRFGsBEss+1iT1IsIGzSuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nwHlpVjA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nwHlpVjA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DF86C116C6; Tue, 27 Jan 2026 07:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769498709; bh=NM/XyGcuu3oC40AjWHvNWgcayap1TyIPrLlqNMwrM1k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nwHlpVjAUt4dHIEIKRYYNtICbchdIO4PS4BHoBalmKmLFKuaBGTgx0x57HuhDNT03 QJZP41o3Q0bN1Wla3i3pM/m16YT6ZP3gPIubbAakGqvBDIrbRRYKpMcAcIifJeEH4t ce9W9LgL69U2JPtrQHEPwjtZ+FY13GlL98uHYUW4vm5b+rTsBM+YWfGXNlCQLGOavc ae2wD7gP2t2o+NnORLMcHB1+aeatGIjHuGRLba+fppZAAlBPPeTVgecBh7R9DUYFki iacaQc++NTBBkdWDmFfN8Geel4YHv1vxCzF1d6E9eADcVmoJmaKJlC+zr3NY77bluZ sehFo4vHlyz3Q== Date: Tue, 27 Jan 2026 09:25:01 +0200 From: Mike Rapoport To: Breno Leitao Cc: Alexander Graf , Pasha Tatashin , Pratyush Yadav , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, SeongJae Park , kernel-team@meta.com Subject: Re: [PATCH v5 1/4] kho: add size parameter to kho_add_subtree() Message-ID: References: <20260126-kho-v5-0-7cd0f69ab204@debian.org> <20260126-kho-v5-1-7cd0f69ab204@debian.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: On Tue, Jan 27, 2026 at 09:23:38AM +0200, Mike Rapoport wrote: > On Mon, Jan 26, 2026 at 08:07:23AM -0800, Breno Leitao wrote: > > kho_add_subtree() assumes the fdt argument is always an FDT and calls > > fdt_totalsize() on it in the debugfs code path. This assumption will > > break if a caller passes arbitrary data instead of an FDT. > > > > When CONFIG_KEXEC_HANDOVER_DEBUGFS is enabled, kho_debugfs_fdt_add() > > calls __kho_debugfs_fdt_add(), which executes: > > > > f->wrapper.size = fdt_totalsize(fdt); > > > > Fix this by adding an explicit size parameter to kho_add_subtree() so > > callers specify the blob size. This allows subtrees to contain > > arbitrary data formats, not just FDTs. Update all callers: > > > > - memblock.c: use fdt_totalsize(fdt) > > - luo_core.c: use fdt_totalsize(fdt_out) > > - test_kho.c: use fdt_totalsize() > > - kexec_handover.c (root fdt): use fdt_totalsize(kho_out.fdt) > > > > Also update kho_in_debugfs_init() to compute sizes using fdt_totalsize() > > for the root and sub-FDTs it processes, since these are known to be > > actual FDT blobs. > > > > Suggested-by: Pratyush Yadav > > Signed-off-by: Breno Leitao > > Reviewed-by: Mike Rapoport (Microsoft) > > > --- > > include/linux/kexec_handover.h | 4 ++-- > > kernel/liveupdate/kexec_handover.c | 8 +++++--- > > kernel/liveupdate/kexec_handover_debugfs.c | 15 +++++++++------ > > kernel/liveupdate/kexec_handover_internal.h | 5 +++-- > > kernel/liveupdate/luo_core.c | 3 ++- > > lib/test_kho.c | 3 ++- > > mm/memblock.c | 2 +- > > 7 files changed, 24 insertions(+), 16 deletions(-) > > > > diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h > > index ac4129d1d7416..abb1d324f42d0 100644 > > --- a/include/linux/kexec_handover.h > > +++ b/include/linux/kexec_handover.h > > @@ -32,7 +32,7 @@ void kho_restore_free(void *mem); > > struct folio *kho_restore_folio(phys_addr_t phys); > > struct page *kho_restore_pages(phys_addr_t phys, unsigned long nr_pages); > > void *kho_restore_vmalloc(const struct kho_vmalloc *preservation); > > -int kho_add_subtree(const char *name, void *fdt); > > +int kho_add_subtree(const char *name, void *fdt, size_t size); > > I'd rename 'void *fdt' to 'void *blob' to make it clearer that subtree isn't > necessary an FDT. Scratch that, I didn't look at the second patch :) > And s/fdt/blob/ in debugfs function names. > All this could be a separate cleanup. > > > -- > Sincerely yours, > Mike. -- Sincerely yours, Mike.