From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380119; b=Rfsgo11HOFXibXTCrqUA2xzgw82ZWrLhmfiQml5W123EGXRlGQ40ZHBizcG82I6FFsPj 3ZHuTJ8NF9dEeD7XfZu3dX8tEv/Cqb6ZsakRogX2ueHOZBeohcJKoEo1yTsHPQgBNgS5t +D0gnVUzFPQHulDZW5fG4rYMAwxafAArwmDXbqS4Ewujx91Z/oA8Nu+vrxUhEL4xcFU/l uvSbCMKXSG/B/dC0LwGdOtiYXmmD8agqg7leBkC11+t+b//xn/eivIq+WuoifBtwoh26Z Me7zGGb9E3xdeNUlha6tjW8EnVySxALrRrNczrqUnUvjRhkHq6Br5U29Ns40of3YmPw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380119; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=awuBzBng1KxjPltQADr+FbPB1BiwHLkXttzBZ2zCHkI=; b=f53VHviIUPiWtDZglmgv0FS+VFRlaJXV6iT8VPf1DH7bmnLuMfe6lCT2IjOzEtvVV3eT saOsDdTxoII9SCkbPjZcjC5WSG6coxKHGyNYeiuuCp2vIlaC9xKCvT1+t63xY/WcPTLwB GzBJuc1Ou17I8EKEec1idjcqIk49S278/MnW95BIHkIRd15/FymHczZlgMtC4AXhTTjSd 2yhOHHlLZyjSnmNwW6TFMbyll/uPXBPz33pk4J37bByM8zF7nLMv8RNRkTIbEtOPwoPtY XCXl2XmdUnfHn648VLMpAwvpx7wHXlaPA9/V80VUqi3rjiQ3KfR669tfbXqAVuEt+lw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ffyL3vZl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 110FC606A32C; Fri, 4 Dec 2026 10:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ffyL3vZl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DD031F000C2; Fri, 4 Dec 2026 10:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380118; bh=awuBzBng1KxjPltQADr+FbPB1BiwHLkXttzBZ2zCHkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ffyL3vZlFbf3Bdhs0pQyOYuDiR2o6O+Vfr/fet1XkB0zj6J4bNhvdX7vCjkl0a2qT UcYgdRUssQdHyEwmoq/JdloIJP4DcwoaDcWfC9IGW2jxmLl3V9d4CcPO8q9ICd/Sj1 YVTvKIYHzEKNYV4Y0EQhkTZ5Q1YdYR/3SvqJ2LpU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pasha Tatashin , Long Wei , Pratyush Yadav , "Mike Rapoport (Microsoft)" , Sasha Levin Subject: [PATCH 7.3 093/742] kho: do not expose incoming sub-blob contents in debugfs Date: Fri, 4 Dec 2026 18:59:17 +0900 Message-ID: <20261204100637.580756446@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Wei [ Upstream commit fa1c0f103fd68558613d3df76e222463c6e4fc37 ] 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: 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 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 directory. The incoming FDT is reserved by KHO and remains exposed as in/fdt, where the same metadata is available. The incoming sub-blob debugfs directory is gone, so remove its description from the KHO admin guide as well. Note that in/sub_fdts has exposed memory KHO does not own since commit c609c144b0e8 ("kexec: add KHO parsing support"), but the use-after-free only became reachable after commit d376e4b55c9a0 ("liveupdate: centralize state management into struct luo_ser") which added kho_restore_free() Fixes: d376e4b55c9a0 ("liveupdate: centralize state management into struct luo_ser") Acked-by: Pasha Tatashin Signed-off-by: Long Wei Reviewed-by: Pratyush Yadav Link: https://patch.msgid.link/20261119095937.826980-1-longwei27@huawei.com Signed-off-by: Mike Rapoport (Microsoft) Signed-off-by: Sasha Levin --- Documentation/admin-guide/mm/kho.rst | 4 -- kernel/liveupdate/kexec_handover_debugfs.c | 47 +--------------------- 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst index 2c26e560bd78a..2f339cf152812 100644 --- a/Documentation/admin-guide/mm/kho.rst +++ b/Documentation/admin-guide/mm/kho.rst @@ -117,7 +117,3 @@ stabilized. kernel's state is in this file in the format of flattened 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. diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate/kexec_handover_debugfs.c index 257ee8a52be66..cb330c1a01ac5 100644 --- a/kernel/liveupdate/kexec_handover_debugfs.c +++ b/kernel/liveupdate/kexec_handover_debugfs.c @@ -10,7 +10,6 @@ #define pr_fmt(fmt) "KHO: " fmt #include -#include #include #include #include @@ -97,8 +96,8 @@ DEFINE_SHOW_ATTRIBUTE(scratch_len); __init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt) { - struct dentry *dir, *sub_fdt_dir; - int err, child; + struct dentry *dir; + int err; INIT_LIST_HEAD(&dbg->fdt_list); @@ -108,54 +107,12 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt) goto err_out; } - sub_fdt_dir = debugfs_create_dir("sub_fdts", dir); - if (IS_ERR(sub_fdt_dir)) { - err = PTR_ERR(sub_fdt_dir); - goto err_rmdir; - } - err = __kho_debugfs_blob_add(&dbg->fdt_list, dir, "fdt", fdt, fdt_totalsize(fdt)); if (err) goto err_rmdir; - 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); - 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); - 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; - } - } - dbg->dir = dir; - dbg->sub_fdt_dir = sub_fdt_dir; return; err_rmdir: -- 2.53.0