Repository navigation
Conversation
When a kernel is built with function prefix padding (such as CONFIG_CALL_PADDING / -fpatchable-function-entry=16,16 or CONFIG_FINEIBT), the function entry point and its __fentry__ NOP are located at insn_offset (rela->offset - 1) rather than at offset 0 of the function section. kpatch_create_ftrace_callsite_sections() already computes insn_offset from rela->offset - 1, but when converting an R_X86_64_NONE relocation into a call to __fentry__, it pointed insn at the start of the section buffer (newdata) instead of newdata + insn_offset, failing with: unexpected instruction at the start of the function Offset insn by insn_offset and drop the redundant reassignment to sym->sec->data->d_buf. Fixes: b958ed6 ("create-diff-object: Add ppc64le mcount support") Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
…ocal checks Clang emits local STT_OBJECT symbols named .compoundliteral (and .compoundliteral.<N> when multiple compound literals exist in a translation unit) for C99 compound literals. since .compoundliteral.<N> contains a dot and does not start with .L, kpatch_is_normal_static_local() identifies them as compiler generated objects as function static local variables and aborts in find_local_sym(). Don't include .compoundliteral* symbols in kpatch_is_normal_static_local(). Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
…atch() MODULE_DEVICE_TABLE() generates local __mod_device_table__* symbols in per-object files that are discarded during linking vmlinux. Add __mod_device_table__* to maybe_discarded_sym() after __export_symbol_* and __gendwarfksyms_*, and skip the symbols in locals_match() by checking maybe_discarded_sym(). Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
…ed name When building livepatches against Clang-compiled kernels compiler-generated local symbols such as .L.str.<N> and <func>.__UNIQUE_ID_ddebug<N> can receive different numerical suffixes between the original vmlinux symbol table and the rebuilt object (for example, when rebuilding the objects for kpatch-build). Relocate the kpatch_mangled_strcmp() to kpatch-elf.c so that it can be used in locals_match() for correlating the mangled numeric suffixes and the dynamic debug ids from LLVM. Only fall back to the different numeric suffixes in lookup_local_symbol() if the exact match is not found within the STT_FILE. Finally, store the resolved symbol names in a struct lookup_result::name, allowing the lookup_local_symbol() to match the targets symbol name in .kpatch.strings and .symbols. Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Pass through LLVM setting if the correct flags are set (CONFIG_CC_IS_CLANG, CONFIG_LD_IS_LLD, and CONFIG_AS_IS_LLVM), and the llvm-objcopy command is accessible. Also pass any KCFLAGS from the environment when kpatch-build exports KCFLAGS for object compilation and the final module build. Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Contributor
|
Hi @howlett thanks for MR, I'll try to review some time next week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Even though kpatch is on its way out, there are a number of users on LTS releases that cannot move to klp just yet. Adding support for clang 20 help those users live patch kernels until they are able to move to the newer live patching available on newer kernels.
This series fixes an x86_64 fentry NOP replacement bug on kernels built with function prefix padding and enables kpatch-build to create live patches for kernels built with Clang/LLD/LLVM. Tested against 6.18 and clang 20.