* [PATCH 0/2] kho: expose incoming sub-blob metadata instead of contents
@ 2026-11-17 9:29 Long Wei
2026-11-17 9:29 ` [PATCH 1/2] " Long Wei
2026-11-17 9:29 ` [PATCH 2/2] docs: kho: describe the in/blobs debugfs file Long Wei
0 siblings, 2 replies; 3+ messages in thread
From: Long Wei @ 2026-11-17 9:29 UTC (permalink / raw)
To: rppt, pasha.tatashin, pratyush, akpm
Cc: graf, leitao, corbet, rdunlap, linux-mm, kexec, linux-doc,
linux-kernel, hewenliang4, Long Wei
Incoming sub-blob pages under kho/in/sub_fdts are owned by their consumers
and have independent lifetimes. Consumers restore and free them at their own
initcall level, which is always earlier than kho_init() (fs_initcall) where
the debugfs view is built. LUO, for example, frees its state in
early_initcall, so in/sub_fdts/LUO ends up pointing at a page that has
already been returned to the page allocator. Reading the file then triggers
a KASAN use-after-free in _copy_to_user(), with the backing page already
marked page_type: f0(buddy).
KHO does not own these pages, so it cannot safely expose their contents at
any point. Instead of trying to track which blobs are still alive, replace
the raw blob nodes with a read-only in/blobs file that reports the name,
physical address and size of every sub-blob referenced by the incoming FDT.
The FDT itself is reserved by KHO and remains available as in/fdt.
The first patch does the change, the second updates the documentation.
Long Wei (2):
kho: expose incoming sub-blob metadata instead of contents
docs: kho: describe the in/blobs debugfs file
Documentation/admin-guide/mm/kho.rst | 6 +--
kernel/liveupdate/kexec_handover_debugfs.c | 83 +++++++++++++++---------------
2 files changed, 45 insertions(+), 44 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] kho: expose incoming sub-blob metadata instead of contents
2026-11-17 9:29 [PATCH 0/2] kho: expose incoming sub-blob metadata instead of contents Long Wei
@ 2026-11-17 9:29 ` Long Wei
2026-11-17 9:29 ` [PATCH 2/2] docs: kho: describe the in/blobs debugfs file Long Wei
1 sibling, 0 replies; 3+ messages in thread
From: Long Wei @ 2026-11-17 9:29 UTC (permalink / raw)
To: rppt, pasha.tatashin, pratyush, akpm
Cc: graf, leitao, corbet, rdunlap, linux-mm, kexec, linux-doc,
linux-kernel, hewenliang4, Long Wei
Incoming sub-blob pages are owned by their consumers and have independent
lifetimes. Some consumers, such as LUO, restore and free their state in
early_initcall, i.e. before kho_init() (fs_initcall) builds the debugfs
view:
early_initcall: luo_early_startup()
-> kho_retrieve_subtree("LUO")
-> kho_restore_free(luo_ser) /* page is freed */
fs_initcall: kho_init()
-> kho_in_debugfs_init()
-> phys_to_virt(luo_ser_phys)
-> debugfs_create_blob("LUO", ...)
debugfs therefore ends up pointing at a page that was already handed back
to the page allocator, and reading the file triggers a use-after-free:
# cat /sys/kernel/debug/kho/in/sub_fdts/LUO
==================================================================
BUG: KASAN: use-after-free in _copy_to_user+0x37/0x60
Read of size 32 at addr ffff88810309c000 by task cat/27436
Call Trace:
<TASK>
kasan_report+0xb9/0xf0
kasan_check_range+0x100/0x1b0
_copy_to_user+0x37/0x60
simple_read_from_buffer+0x77/0xd0
read_file_blob+0x75/0xa0
vfs_read+0x12d/0x520
ksys_read+0xc3/0x160
do_syscall_64+0x97/0x4b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x1fd
pfn:0x10309c
flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff)
page_type: f0(buddy)
==================================================================
The page is already in the buddy allocator (page_type: f0(buddy),
refcount 0), which confirms it was freed before the debugfs view was
created.
KHO does not own these pages, so it cannot safely expose their contents at
all. Drop the in/sub_fdts raw blob nodes and replace them with a
read-only in/blobs metadata file that lists the name, physical address and
size of every incoming sub-blob. The FDT itself is reserved by KHO and is
still exposed as in/fdt.
Fixes: 062dd306d99c ("kho: fix kho_in_debugfs_init() to handle non-FDT blobs")
Signed-off-by: Long Wei <longwei27@huawei.com>
---
kernel/liveupdate/kexec_handover_debugfs.c | 83 +++++++++++-----------
1 file changed, 42 insertions(+), 41 deletions(-)
diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate/kexec_handover_debugfs.c
index 7d74477da0b7..3624d4bf44b2 100644
--- a/kernel/liveupdate/kexec_handover_debugfs.c
+++ b/kernel/liveupdate/kexec_handover_debugfs.c
@@ -95,67 +95,68 @@ static int bootmem_len_show(struct seq_file *m, void *v)
}
DEFINE_SHOW_ATTRIBUTE(bootmem_len);
-__init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt)
+static int kho_in_blobs_show(struct seq_file *m, void *v)
{
- struct dentry *dir, *sub_fdt_dir;
- int err, child;
-
- INIT_LIST_HEAD(&dbg->fdt_list);
-
- dir = debugfs_create_dir("in", debugfs_root);
- if (IS_ERR(dir)) {
- err = PTR_ERR(dir);
- goto err_out;
- }
+ const void *fdt = m->private;
+ int child, len;
- sub_fdt_dir = debugfs_create_dir("sub_fdts", dir);
- if (IS_ERR(sub_fdt_dir)) {
- err = PTR_ERR(sub_fdt_dir);
- goto err_rmdir;
+ if (fdt_check_header(fdt)) {
+ seq_puts(m, "invalid incoming FDT\n");
+ return 0;
}
- err = __kho_debugfs_blob_add(&dbg->fdt_list, dir, "fdt", fdt,
- fdt_totalsize(fdt));
- if (err)
- goto err_rmdir;
-
+ seq_puts(m, "# name pa size\n");
fdt_for_each_subnode(child, fdt, 0) {
- int len = 0;
const char *name = fdt_get_name(fdt, child, NULL);
const u64 *blob_phys;
const u64 *blob_size;
- void *blob;
blob_phys = fdt_getprop(fdt, child,
KHO_SUB_TREE_PROP_NAME, &len);
- if (!blob_phys)
- continue;
- if (len != sizeof(*blob_phys)) {
- pr_warn("node %s prop %s has invalid length: %d\n",
- name, KHO_SUB_TREE_PROP_NAME, len);
+ if (!blob_phys || len != sizeof(*blob_phys))
continue;
- }
blob_size = fdt_getprop(fdt, child,
KHO_SUB_TREE_SIZE_PROP_NAME, &len);
- if (!blob_size || len != sizeof(*blob_size)) {
- pr_warn("node %s missing or invalid %s property\n",
- name, KHO_SUB_TREE_SIZE_PROP_NAME);
+ if (!blob_size || len != sizeof(*blob_size))
continue;
- }
- blob = phys_to_virt(*blob_phys);
- err = __kho_debugfs_blob_add(&dbg->fdt_list, sub_fdt_dir, name,
- blob, *blob_size);
- if (err) {
- pr_warn("failed to add blob %s to debugfs: %pe\n",
- name, ERR_PTR(err));
- continue;
- }
+ seq_printf(m, "%s 0x%016llx %llu\n", name,
+ (u64)*blob_phys, (u64)*blob_size);
}
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(kho_in_blobs);
+
+/*
+ * Show the metadata of the sub-blobs referenced by the incoming FDT. Each
+ * line contains the name, physical address and size of a sub-blob. The raw
+ * contents of the sub-blobs are not exposed.
+ */
+__init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt)
+{
+ struct dentry *dir;
+ int err;
+
+ INIT_LIST_HEAD(&dbg->fdt_list);
+
+ dir = debugfs_create_dir("in", debugfs_root);
+ if (IS_ERR(dir)) {
+ err = PTR_ERR(dir);
+ goto err_out;
+ }
+
+ err = __kho_debugfs_blob_add(&dbg->fdt_list, dir, "fdt", fdt,
+ fdt_totalsize(fdt));
+ if (err)
+ goto err_rmdir;
+
+ debugfs_create_file("blobs", 0400, dir, (void *)fdt,
+ &kho_in_blobs_fops);
+
dbg->dir = dir;
- dbg->sub_fdt_dir = sub_fdt_dir;
+ dbg->sub_fdt_dir = NULL;
return;
err_rmdir:
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] docs: kho: describe the in/blobs debugfs file
2026-11-17 9:29 [PATCH 0/2] kho: expose incoming sub-blob metadata instead of contents Long Wei
2026-11-17 9:29 ` [PATCH 1/2] " Long Wei
@ 2026-11-17 9:29 ` Long Wei
1 sibling, 0 replies; 3+ messages in thread
From: Long Wei @ 2026-11-17 9:29 UTC (permalink / raw)
To: rppt, pasha.tatashin, pratyush, akpm
Cc: graf, leitao, corbet, rdunlap, linux-mm, kexec, linux-doc,
linux-kernel, hewenliang4, Long Wei
The incoming sub-blob raw nodes under kho/in/sub_fdts no longer exist:
the sub-blob pages are owned by their consumers and may already be freed
by the time the debugfs view is created, so exposing them was unsafe.
Document the in/blobs metadata file that replaces them.
Signed-off-by: Long Wei <longwei27@huawei.com>
---
Documentation/admin-guide/mm/kho.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst
index 902d171a780a..602c8ce90e9a 100644
--- a/Documentation/admin-guide/mm/kho.rst
+++ b/Documentation/admin-guide/mm/kho.rst
@@ -118,6 +118,6 @@ stabilized.
device tree. This file may disappear when all consumers of
it finished to interpret their metadata.
-``/sys/kernel/debug/kho/in/sub_fdts/``
- Similar to ``kho/out/sub_fdts/``, but contains sub blobs
- of KHO producers passed from the old kernel.
+``/sys/kernel/debug/kho/in/blobs``
+ Metadata for the sub-blobs referenced by the incoming FDT. Each line
+ contains the name, physical address and size of a sub-blob.
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-17 9:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 9:29 [PATCH 0/2] kho: expose incoming sub-blob metadata instead of contents Long Wei
2026-11-17 9:29 ` [PATCH 1/2] " Long Wei
2026-11-17 9:29 ` [PATCH 2/2] docs: kho: describe the in/blobs debugfs file Long Wei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®