[Devel] [PATCH hci-8.2 v2 00/28] ms/objtool: fix silently wrong livepatches by klp-build

Eva Kurchatova (Virtuozzo) eva.kurchatova at virtuozzo.com
Thu Nov 26 09:15:29 MSK 2026


On 11/26/26 07:06, Eva Kurchatova wrote:
> Patchset for tasks:
> https://virtuozzo.atlassian.net/browse/VSTOR-128510
> https://virtuozzo.atlassian.net/browse/VSTOR-156924
> https://virtuozzo.atlassian.net/browse/VSTOR-157091
>
> klp-build in 26.x is the RHEL 10.2 import. Mainline has fixed many bugs
> in it since, and the objtool in it fails 31 of 48 mainline tests.
>
> This series takes only the mainline fixes for bugs that a vz10 build
> (x86_64, gcc) can hit and that make klp-build produce a livepatch which
> builds but is broken, or refuse a common patch. Patches 1-19 are for
> VSTOR-128510, patches 20-28 for VSTOR-156924 (1-19 are prerequisites):
>
> - pointers to const data compared against a private copy (13)
> - klp relocations to exports of another module put in a section the
>    livepatch loader never applies, e.g. jump into garbage (16-18)
> - static symbols bound to an export of the same name (19)
> - strings and data cloned at the wrong offset (3, 4)
> - module static keys not rejected at build time (1, 6)
> - WARN_ONCE() flags correlated between unrelated call sites (5)
> - functions using pr_debug() in modules can't be patched (2); objtool
>    crashes on empty sections (8) and corrupts a relocation (10)
> - symbol positions of the same-named static symbols counted in same
>    order as vmlinux.o, which the final link reorders (22, 23, 25, 28)
> - match the .cold part of a function by name (20)
> - fix NULL dereference when printing a code symbol (21)
> - fix x86 alternative replacement (24, 26)
> - fix new references to an export of another module (27)
>
> Patches 7, 9, 11 and 12 are mainline prerequisites of 13. The picks
> match mainline line for line, except 22 and 23, which have a rebase
> note.
>
> Since patch 13, a named const object is correlated, and the livepatch
> references the original. Patches 14 and 15 are original. Patch 15 makes
> klp diff fail when a correlated const object changes, replacing a much
> larger upstream correlation rewrite, 6016dd33a10a, too large to take.
> Patch 14 fixes an existing mainline problem, and fails klp diff if the
> section would be cloned due to one of its objects, or size-less one.
> See VSTOR-157091 for details, patch 14 to be sent mainline too.
>
> Patch 22 makes klp-build builds emit a .klp.symid table, a section that
> is not allocated; kernels built without klp-build do not change.
>
> Tested with klp-build on rh10-6.12.0-211.75.1.26.4.vz10 in QEMU.
>
> Changes in v3:
> - Merged the VSTOR-156924 proposal as patches 20-28, not posted before.
> - New patch 14: Check .rodata section labels and prevent object cloning.
> - Patch 15: Check an object which the patch makes const, compare only
>    the section of a target that no symbol contains, lowercase subject.
> - Cover letter: Renumber patches, update covered tasks.
>
> Link to v2: http://lore.virtuozzo.com/kernel/179560292324.21954.16900360366849940769.b4-review@b4/T/#t
>
> Changes in v2:
> - Patch 14: Fail klp diff when a correlated .rodata object changed.
> - Cover letter: Reflect the .rodata object handling change.
> - Reviewed-by: Sashiko on patches 1-12.
>
> Link to v1: http://lore.virtuozzo.com/kernel/20261124050655.1853940-1-eva.kurchatova@virtuozzo.com/T/#t
>
>
> Eva Kurchatova (2):
>    objtool/klp: use the section symbol for .rodata labels
>    objtool/klp: reject changed .rodata objects
>
> Joe Lawrence (4):
>    ms/objtool/klp: fix data alignment in __clone_symbol()
>    ms/objtool/klp: Fix create_fake_symbols() skipping entsize-based
>      sections
>    ms/objtool/klp: Normalize Module.symvers paths to module names
>    ms/objtool/klp: Allow new references to module exports
>
> Josh Poimboeuf (21):
>    ms/objtool/klp: Fix detection of corrupt static branch/call entries
>    ms/objtool/klp: Disable unsupported pr_debug() usage
>    ms/objtool: Fix data alignment in elf_add_data()
>    ms/objtool/klp: Fix .data..once static local non-correlation
>    ms/objtool/klp: Fix handling of zero-length .altinstr_replacement
>      sections
>    ms/objtool/klp: Fix cloning of zero-length section symbols
>    ms/objtool/klp: Fix relocation conversion failures for R_X86_64_NONE
>    ms/objtool/klp: Fix reloc corruption in convert_reloc_sym_to_secsym()
>    ms/objtool/klp: Simplify reloc symbol conversion
>    ms/objtool: Move mark_rodata() to elf.c
>    ms/objtool/klp: Fix pointer comparisons for rodata objects
>    ms/objtool/klp: Fix module name normalization for paths with dots
>    ms/objtool/klp: Fix cross-module klp relocation section naming
>    ms/objtool/klp: Don't match local symbols against exports
>    ms/objtool: Fix .cold function detection for duplicate symbols
>    ms/objtool/klp: Avoid NULL pointer dereference when printing code
>      symbol name
>    ms/objtool/klp: Add .klp.symid for sympos disambiguation
>    ms/objtool/klp: Fix symbol resolution for duplicate data symbols
>    ms/objtool/klp: Fix size of empty special section entries
>    ms/objtool/klp: Fix vmlinux .klp.symid link error for .no_trim_symbol
>      symbols
>    ms/objtool/klp: Ignore replacement offset of empty x86 alternatives
>
> Puranjay Mohan (1):
>    ms/objtool/klp: Fix vmlinux .klp.symid link error for .exitcall.exit
>      symbols
>
>   include/asm-generic/vmlinux.lds.h       |  10 +-
>   scripts/Makefile.vmlinux_o              |   3 +
>   scripts/livepatch/klp-build             |   7 +
>   scripts/mod/modpost.c                   |   1 +
>   tools/objtool/Build                     |   4 +-
>   tools/objtool/arch/x86/special.c        |  27 ++
>   tools/objtool/builtin-check.c           |   7 +
>   tools/objtool/check.c                   |  18 +-
>   tools/objtool/elf.c                     |  69 +++-
>   tools/objtool/include/objtool/builtin.h |   1 +
>   tools/objtool/include/objtool/elf.h     |  25 +-
>   tools/objtool/include/objtool/klp.h     |  29 +-
>   tools/objtool/include/objtool/special.h |   7 +
>   tools/objtool/klp-diff.c                | 471 ++++++++++++++++--------
>   tools/objtool/klp-post-link.c           |  53 +--
>   tools/objtool/klp-symid.c               | 119 ++++++
>   tools/objtool/klp-sympos.c              | 411 +++++++++++++++++++++
>   17 files changed, 1073 insertions(+), 189 deletions(-)
>   create mode 100644 tools/objtool/klp-symid.c
>   create mode 100644 tools/objtool/klp-sympos.c


Sorry, wrong series version. This is a v3, as mentioned throughout the 
rest of the cover letter. I missed part of the git invocation shell 
auto-fill and didn't fix it up in editor. I can re-send if needed.



More information about the Devel mailing list