kpatch/kpatch-build
Josh Poimboeuf 629b5acf3d kpatch-build: Fix setlocalversion issue with 6.3 kernel
The kernel has a VERMAGIC_STRING, e.g. "6.2.0".  The module loader uses
that string to ensure that all loaded modules' version strings match the
kernel's.

If the kernel source is in a git tree, and if there are uncommitted
changes, the version string will have a '+' or "-dirty" appended to it,
like "6.1.0+" or "6.2.0-dirty".  This dirty tree detection is done by
the setlocalversion script.

This affects kpatch-build in a few ways.  When it builds the original
kernel, in some cases there are uncommitted changes to the makefiles.
When it builds the patched kernel, there are additional uncommitted
changes due to the .patch file being applied.

We want to avoid the VERMAGIC_STRING changing between builds.  Otherwise
it would cause problems:

  - object code which uses that string would change unnecessarily,
    causing a false positive change detected by create-diff-object

  - the linked patch module would report the wrong version, resulting in
    the module failing to load due to version mismatch.

Up until now, the version was prevented from changing by running
`setlocalversion --save-scmversion` before the build.  That command
hard-codes the version by saving it to a file which is then
automatically read later during future invocations of the kernel build.

Unfortunately that feature was removed in the 6.3 merge window with
commit f6e09b07cc12 ("kbuild: do not put .scmversion into the source
tarball").  So we need to come up with a new approach.

Fix it by temporarily replacing the setlocalversion script with a
one-liner which just echo's the original version.  I think this is
unfortunately the best we can do, as we really can't handle
VERMAGIC_STRING changing, either during/between kernel builds or during
the module link.

Fixes #1335.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2023-03-13 14:40:24 -07:00
..
gcc-plugins gcc-plugin: update headers for gcc-12 2022-09-27 16:41:48 -04:00
insn insn: get it to compile in create-diff-object 2014-05-30 15:19:57 -05:00
Makefile kpatch/s390: Enable kpatch build support 2022-05-20 15:50:29 +02:00
create-diff-object.c create-diff-object: batch report unsupported sibling calls 2023-02-17 11:49:38 -05:00
create-klp-module.c create-diff-object: rename "dynrela" -> "klp_reloc" 2022-12-01 14:00:09 -08:00
create-kpatch-module.c kpatch-elf: pass new ELF output file mode to kpatch_write_output_elf() 2020-09-25 09:30:13 -04:00
kpatch-build kpatch-build: Fix setlocalversion issue with 6.3 kernel 2023-03-13 14:40:24 -07:00
kpatch-cc kpatch-build: fix "make check" 2022-11-30 19:04:23 -08:00
kpatch-elf.c kpatch-build: for clang, use .strtab if no .shstrtab 2022-09-27 15:56:06 -04:00
kpatch-elf.h create-diff-object: rename "dynrela" -> "klp_reloc" 2022-12-01 14:00:09 -08:00
kpatch-intermediate.h lookup: rename 'pos' to 'sympos' 2020-04-06 15:18:58 -05:00
kpatch.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
list.h new .fixup group size algorithm 2014-09-15 14:54:57 -05:00
log.h create-diff-object: use errx() instead of err() 2022-11-30 12:58:31 -08:00
lookup.c kpatch-build: use err.h instead of error.h for musl support 2022-08-05 08:52:03 +02:00
lookup.h Switch to per-file lookup table pointers. 2021-08-17 09:37:44 +02:00