From: Mike Rapoport <rppt@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Alexander Graf <graf@amazon.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>,
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 <sj@kernel.org>,
kernel-team@meta.com
Subject: Re: [PATCH v5 1/4] kho: add size parameter to kho_add_subtree()
Date: Tue, 27 Jan 2026 09:23:30 +0200 [thread overview]
Message-ID: <aXhn8ieKtj3T3FCc@kernel.org> (raw)
In-Reply-To: <20260126-kho-v5-1-7cd0f69ab204@debian.org>
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 <pratyush@kernel.org>
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> 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.
And s/fdt/blob/ in debugfs function names.
All this could be a separate cleanup.
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-01-27 7:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 16:07 [PATCH v5 0/4] kho: history: track previous kernel version and kexec boot count Breno Leitao
2026-01-26 16:07 ` [PATCH v5 1/4] kho: add size parameter to kho_add_subtree() Breno Leitao
2026-01-27 7:23 ` Mike Rapoport [this message]
2026-01-27 7:25 ` Mike Rapoport
2026-01-26 16:07 ` [PATCH v5 2/4] kho: rename fdt parameter to blob in kho_add/remove_subtree() Breno Leitao
2026-01-27 7:26 ` Mike Rapoport
2026-01-27 13:41 ` Breno Leitao
2026-01-26 16:07 ` [PATCH v5 3/4] kho: kexec-metadata: track previous kernel chain Breno Leitao
2026-01-27 7:31 ` Mike Rapoport
2026-01-26 16:07 ` [PATCH v5 4/4] kho: document kexec-metadata tracking feature Breno Leitao
2026-01-27 7:32 ` Mike Rapoport
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=aXhn8ieKtj3T3FCc@kernel.org \
--to=rppt@kernel.org \
--cc=clm@fb.com \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=riel@surriel.com \
--cc=rmikey@meta.com \
--cc=sj@kernel.org \
--cc=usamaarif642@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.