dynup / kpatch

kpatch - live kernel patching
GNU General Public License v2.0
1.49k stars 305 forks source link

'-'/'_' mismatch for OOT modules #1286

Closed liu-song-6 closed 2 years ago

liu-song-6 commented 2 years ago

While building livepatch for an OOT module, we hit issue with '-'/'_' mismatch. The OOT module has name as abc_xyz, while the livepatch module is build as abc-xyz. The same mismatch also happens to klp.rela.abc-xyz section (this is a 5.6 based kernel).

scripts/Makefile.lib changes module name in

# These flags are needed for modversions and compiling, so we define them here
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
# end up in (or would, if it gets compiled in)
name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
name-fix = $(call stringify,$(call name-fix-token,$1))

Can we do something similar in kpatch-build?

jpoimboe commented 2 years ago

Does this fix it?

diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build
index 02504e6..296fa48 100755
--- a/kpatch-build/kpatch-build
+++ b/kpatch-build/kpatch-build
@@ -1100,6 +1100,7 @@ for i in $FILES; do
                        SYMVERS_FILE="$BUILDDIR/Module.symvers"
                elif [[ "$(basename "$KOBJFILE")" = "$(basename "$OOT_MODULE")" ]]; then
                        KOBJFILE_NAME="$(basename --suffix=.ko "$OOT_MODULE")"
+                       KOBJFILE_NAME="${KOBJFILE_NAME//-/_}"
                        KOBJFILE_PATH="$OOT_MODULE"
                        SYMTAB="${TEMPDIR}/module/${KOBJFILE_NAME}.symtab"
                        SYMVERS_FILE="$TEMPDIR/Module.symvers"
liu-song-6 commented 2 years ago

It does fix the issue! Thanks!