From cc448e44f6e9fc83f1527f926f52ebfa5a3d1ce9 Mon Sep 17 00:00:00 2001 From: Christian Aurich Zanettini Martins Date: Tue, 3 Nov 2026 12:39:28 -0300 Subject: [PATCH 1/2] liveupdate: check for duplicate session before growing block set luo_session_insert() grows the outgoing block set before checking for a duplicate session name. On -EEXIST the new block stays in the set. If the session count is an exact multiple of the per-block capacity (51 with 4K pages), that block stays empty. It is serialized with count 0, which kho_block_set_restore() rejects in the next kernel: luo: Block contains invalid entry count: 0 Kernel panic - not syncing: The incoming tree failed to initialize properly [-EINVAL], disabling live update Check for the duplicate before growing the block set, as luo_preserve_file() does with the token. Fixes: 2a441a14c2c0 ("liveupdate: Remove limit on the number of sessions") Cc: stable@vger.kernel.org Signed-off-by: Christian Aurich Zanettini Martins Reviewed-by: Pratyush Yadav (Google) Link: https://patch.msgid.link/20261103153928.716753-1-christian.aurichzm@gmail.com Reviewed-by: Pasha Tatashin Signed-off-by: Mike Rapoport (Microsoft) --- kernel/liveupdate/luo_session.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c index f48e9a4185f9..74bc66929f4b 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -176,16 +176,6 @@ static int luo_session_insert(struct luo_session_header *sh, guard(rwsem_write)(&sh->rwsem); - /* - * For outgoing we should make sure there is room in serialization array - * for new session. - */ - if (sh == &luo_session_global.outgoing) { - err = kho_block_set_grow(&sh->block_set, sh->count + 1); - if (err) - return err; - } - /* * For small number of sessions this loop won't hurt performance * but if we ever start using a lot of sessions, this might @@ -196,6 +186,17 @@ static int luo_session_insert(struct luo_session_header *sh, if (!strncmp(it->name, session->name, sizeof(it->name))) return -EEXIST; } + + /* + * For outgoing we should make sure there is room in serialization array + * for new session. + */ + if (sh == &luo_session_global.outgoing) { + err = kho_block_set_grow(&sh->block_set, sh->count + 1); + if (err) + return err; + } + list_add_tail(&session->list, &sh->list); sh->count++; From 58c5852ca96c58cdfdb9646870b217fc54d06a97 Mon Sep 17 00:00:00 2001 From: Greg Thelen Date: Thu, 22 Oct 2026 22:45:18 -0700 Subject: [PATCH 2/2] kho: check fdt_phys in is_kho_boot() is_kho_boot() is called early in boot before the linear memory map is initialized, so calling phys_to_virt() via kho_get_fdt() there is invalid. On arm64 (and similarly in upcoming riscv64 support), this triggers BUG_ONs in debug builds, such as: kernel BUG at ./arch/arm64/include/asm/memory.h:377! Internal error: Oops - BUG: 00000000f2000800 [#1] SMP Call trace: is_kho_boot+0x2c/0x38 (P) efi_init+0x94/0xf8 setup_arch+0xf0/0x240 start_kernel+0x84/0x490 __primary_switched+0x88/0x98 Use kho_in.fdt_phys in is_kho_boot() directly instead of translating it to a virtual address. Fixes: d6d511639185 ("kexec: introduce is_kho_boot()") Signed-off-by: Greg Thelen Reviewed-by: Pratyush Yadav (Google) Link: https://patch.msgid.link/20261023054518.3258350-1-gthelen@google.com [Pasha: massaged the changelog] Signed-off-by: Pasha Tatashin --- kernel/liveupdate/kexec_handover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 6f1f55fe3181..42c6609a1766 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1643,7 +1643,7 @@ EXPORT_SYMBOL_GPL(kho_restore_free); */ bool is_kho_boot(void) { - return !!kho_get_fdt(); + return !!kho_in.fdt_phys; } EXPORT_SYMBOL_GPL(is_kho_boot);