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 E306632D0D8 for ; Tue, 27 Jan 2026 07:23:38 +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=1769498619; cv=none; b=kA6we0OXL3REkpT6bKcPkJm/QhphhYLlyZ9pdqUpLjNuC5r6NCKSbNf4Bv6bYRhttI8J12HqU3OyG/xe+wKnk8gCapsuxZ5rqAWivqfAYQiAMf8IlQ1fQwXM5GqufwEeKdBMFz+iCYeURtJ0uzlba8bHdHCtXYIusAcgFxQljaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769498619; c=relaxed/simple; bh=wKc6TL0A4RPyPSsNR6BFVNJfOo7cACM6wopJvwkAz0g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HTJFm8voM5nH2YRJCzMlFeVPch1/gKdB6QEIRBuuvqhv4+CVkMugykkfHQAc5C0pN6ZFtnUQPCFmPKMvyMlKTZxZppmUJqcc3+OD7gfVsCBSP+4+SMm41W9d7TP9MxrgsJpEK8RwjXFx07UtcjTjG6aVjmy8n9Ak4DqAuuVlXxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G4bBJQeU; 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="G4bBJQeU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F0FDC116C6; Tue, 27 Jan 2026 07:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769498618; bh=wKc6TL0A4RPyPSsNR6BFVNJfOo7cACM6wopJvwkAz0g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G4bBJQeU/o9hOCFqmG0i2rEDHAXUQpCc0MJKYS6Y5c/RUILsdmi8lxJVvxAa+Cjl6 L0Fkyp58vRmqs9H7LMt7ccQ+bhA0PGlobSQELyJcEpBhrnS9bcNhXDAOOySeHifhwh oDWSNMFxC1W1odL6Lv2avlJWJDfi1sEh9IgV+zqZAH3hKAD3zzoNijv8EfZST1APKh c2cbZvdVdf5wtPe+E+4Sg4BWBhIc1AJn5O9Dhz9u3+/MsiLxHi5Mjd/fPCSoZe7Vip X5DbMcjA5hw0brxwPZ8L7gLZpTpER20rkSCVGNiFynFI/cjdd9wpJkSWViWwE4dk4b 6AzxEMzqK1u9w== Date: Tue, 27 Jan 2026 09:23:30 +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: <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 > 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. And s/fdt/blob/ in debugfs function names. All this could be a separate cleanup. -- Sincerely yours, Mike.