From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries
Date: Thu, 26 Nov 2026 15:30:26 +0100 [thread overview]
Message-ID: <20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-13-0ec8eaadf1bc@virtuozzo.com> (raw)
In-Reply-To: <20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-0-0ec8eaadf1bc@virtuozzo.com>
From: Josh Poimboeuf <jpoimboe@kernel.org>
Patching a function which references a static key living in a kernel
module is unsupported due to ordering issues inherent to late module
patching:
1) Load a livepatch module which has a __jump_table entry which needs
a klp reloc to reference static key K which lives in module M.
2) The __jump_table klp reloc does *not* get resolved because module M
is not yet loaded.
3) jump_label_add_module() corrupts memory (or causes a panic) when
dereferencing the uninitialized pointer to key K.
validate_special_section_klp_reloc() intends to prevent that from ever
happening by catching it at build time. However, it incorrectly assumes
the special section entry's reloc symbol references have already been
converted from section symbols to object symbols, causing the validation
to miss corruption in extracted static branch/call table entries.
Make sure the references have been properly converted before doing the
validation.
Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Song Liu <song@kernel.org>
Reviewed-and-tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/124ad747b751df0df1725eff89de8332e3fb26d6.1770759954.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
(cherry picked from commit f9fb44b0ecefc1f218db56661ed66d4e8d67317d)
https://virtuozzo.atlassian.net/browse/VSTOR-157133
Feature: klp-build support
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
tools/objtool/klp-diff.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 62c9dae25cebf..e27cde34c1a18 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1368,6 +1368,9 @@ static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym
const char *sym_modname;
struct export *export;
+ if (convert_reloc_sym(e->patched, reloc))
+ continue;
+
/* Static branch/call keys are always STT_OBJECT */
if (reloc->sym->type != STT_OBJECT) {
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-26 14:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:30 [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 01/14] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure Konstantin Khorenko
2026-12-01 0:34 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 02/14] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
2026-12-01 0:34 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 03/14] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
2026-12-01 0:35 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 04/14] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
2026-12-01 0:36 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 05/14] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
2026-12-01 0:37 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 06/14] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
2026-12-01 0:38 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 07/14] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
2026-12-01 0:38 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 08/14] ms/objtool: Fix data alignment in elf_add_data() Konstantin Khorenko
2026-12-01 0:39 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 09/14] ms/objtool/klp: fix data alignment in __clone_symbol() Konstantin Khorenko
2026-12-01 0:39 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 10/14] ms/objtool/klp: Fix module name normalization for paths with dots Konstantin Khorenko
2026-12-01 0:40 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 11/14] ms/objtool/klp: Normalize Module.symvers paths to module names Konstantin Khorenko
2026-12-01 0:40 ` no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 12/14] ms/objtool/klp: Fix cross-module klp relocation section naming Konstantin Khorenko
2026-12-01 0:41 ` no-reply
2026-11-26 14:30 ` Konstantin Khorenko [this message]
2026-12-01 0:43 ` [Devel] [PATCH hci-8.1 13/14] ms/objtool/klp: Fix detection of corrupt static branch/call entries no-reply
2026-11-26 14:30 ` [Devel] [PATCH hci-8.1 14/14] ms/objtool/klp: Don't match local symbols against exports Konstantin Khorenko
2026-12-01 0:43 ` no-reply
2026-11-26 14:46 ` [Devel] [PATCH hci-8.1 00/14] objtool/klp and KVM fixes for the 8.1 kernel Konstantin Khorenko
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=20261126-khorenko-vstor-157133-klp-and-kvm-fixes-v1-13-0ec8eaadf1bc@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=ptikhomirov@virtuozzo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox