Commit Graph

2341 Commits

Author SHA1 Message Date
Joe Lawrence
4b01ee2698
Merge pull request #1388 from ryanbsull/integration-tests-rhel-9.4-final
test/integration/rhel-9.4: add kernel-5.14.0-427.13.1.el9_4 tests
2024-04-23 16:17:21 -04:00
Joe Lawrence
b448e7d2a9
Merge pull request #1389 from ryanbsull/integration-tests-rhel-8.10-final
test/integration/rhel-8.10: add kernel-4.18.0-552.el8_10 tests
2024-04-23 16:17:08 -04:00
Joe Lawrence
3650db4c2d test/integration/rhel-9.4: add kernel-5.14.0-427.13.1.el9_4 tests
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2024-04-23 14:30:15 -04:00
Joe Lawrence
560318641a test/integration/rhel-8.10: add kernel-4.18.0-552.el8_10 tests
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2024-04-23 14:29:19 -04:00
Joe Lawrence
b363972b79
Merge pull request #1372 from anatasluo/master
kpatch-build: add support for OpenCloudOS
2024-03-26 09:17:18 -04:00
Longjun Luo
57936d3fad kpatch-build: add support for OpenCloudOS
OpenCloudOS is a centos-like Linux distribution.
I test kpatch in OpenCloudOS V8 and V9.
It works well in V9. But v8 itself has two problems:
1. no available epol repo, so kpatch can't install ccache.
2. executing 'uname -r' can't get an accurate kernel version.

Both problems have been notified to the OpenCloudOS community.
After they fix these problems, kpatch will work well in all versions.

Signed-off-by: Longjun Luo <luolongjuna@gmail.com>
2024-03-19 10:51:07 +08:00
Joe Lawrence
4077d87045
Merge pull request #1376 from joe-lawrence/lonely-syscall
kmod: maintain syscall metadata sections in kpatch syscall macros
2024-03-06 10:32:38 -05:00
Joe Lawrence
906bb8f393 kmod: maintain syscall metadata sections in kpatch syscall macros
The KPATCH_SYSCALL_DEFINEn macros in kpatch-syscall.h do not provide the
same syscall metadata (saved in the __syscalls_metadata and
_ftrace_events ELF sections) as the kernel.  These same macros also
instruct kpatch-build to ignore changes to these sections.  This works
fine as long as there are other unmodified syscalls present in the
object file.  However, if not, the kpatch syscall macros may result in
either metadata ELF sections not appearing in the patched object file.
The create-diff-object program expects to encounter any ELF section that
has been marked by KPATCH_IGNORE_SECTION in the patched object file.

To avoid this limitation, create dummy __syscalls_metadata and
_ftrace_events entries for the kpatch-modified syscall.  The specific
values shouldn't matter since their sections will still be marked with
KPATCH_IGNORE_SECTION and now their presence will be guarenteed for
create-diff-object.

Closes: #1375 ("kpatch-build error when modifying an object file's only syscall")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-02-29 16:58:45 -05:00
Josh Poimboeuf
0edd6e42bf
Merge pull request #1368 from wardenjohn/devel
Support Anolis OS in a more elegant way
2024-01-22 11:58:58 -06:00
zhangyongde.zyd
d511792998 kpatch-build: Support distro Anolis OS
Support Anolis OS

Signed-off-by: Wardenjohn<zhangwarden@gmail.com>
2024-01-17 15:44:47 +08:00
zhangyongde.zyd
89c494f023 kpatch-build: simplify distro support
Rather than adding yet another set of conditionals to handle the Anolis
OS distribution, refactor the SUPPORTED_DISTROS code using an
associative array.  The array is keyed by the short distro name, and
contains the longer distribution description.

Signed-off-by: Wardenjohn<zhangwarden@gmail.com>
2024-01-17 12:45:17 +08:00
Joe Lawrence
032c8d2627
Merge pull request #1365 from ryanbsull/integration-tests-rhel-9.3-final
test/integration/rhel-9.3: integration testing for rhel-9.3
2024-01-09 21:33:31 -05:00
Joe Lawrence
131747507f
Merge pull request #1367 from ZhangHongchen1/check_gawk
kpatch-build: check if gawk exist
2024-01-09 21:32:22 -05:00
Hongchen Zhang
e4da489e7e kpatch-build: check if gawk is installed
kpatch-build uses gawk to find special section, but gawk is not
always installed. So check if gawk is installed.

Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
2023-12-12 16:43:15 +08:00
Ryan Sullivan
e4a2215987 test/integration/rhel-9.3: integration testing for rhel-9.3
Provides integration tests for rhel-9.3 (kernel-5.14.0-362.8.1.el9_3)

Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2023-12-05 12:22:45 -05:00
Joe Lawrence
8513926844
Merge pull request #1366 from ryanbsull/integration-tests-rhel-8.9-final
test/integration/rhel-8.9: integration testing for rhel-8.9
2023-12-05 12:00:41 -05:00
Ryan Sullivan
452047381f test/integration/rhel-8.9: integration testing for rhel-8.9
Provides integration tests for rhel-8.9 (kernel-4.18.0-513.5.1.el8_9),
note that module.test is from the linux-6.2/ directory and not
rhel-8.8/

Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2023-12-05 11:58:55 -05:00
Josh Poimboeuf
922cd45809
Merge pull request #1358 from heuza/fix_ub
Fix undefined behavior problem when using list_foreach_entry
2023-09-11 19:17:04 -05:00
Joe Lawrence
089e74e8f6
Merge pull request #1359 from laokz/master
kpatch-build: fix missed parameter of verify_patch_files
2023-09-11 17:46:24 -04:00
laokz
671fe2ce01 kpatch-build: fix missed parameter of verify_patch_files
Verify_patch_files() use `lsdiff` to get patches' path and verify
they are supported. To be consistent with apply_patches() which
using `patch -p1`, `lsdiff` should use '--strip=1' paremeter.

Close: #1357

Signed-off-by: Kai Zhang <zhangkai@iscas.ac.cn>
2023-08-28 22:13:15 +08:00
Weinan Liu
fb22714ae9 Fix undefined behavior problem when using list_foreach_entry
This upstream list.h offsetof implementation rely on undefined behavior implementation. Using __builtin_offsetof to fix this problem.
2023-08-10 00:22:53 +00:00
Joe Lawrence
f594a5c3ea
Merge pull request #1352 from joe-lawrence/bump-v0.9.9
Bump to version v0.9.9
2023-07-28 12:12:05 -04:00
Joe Lawrence
372bde7cd9 Bump to version v0.9.9
Updates of interest:
v0.9.9:
- Support for gcc-13
- Support for Linux 6.2
- Support for UBSAN kernels
- Fix handling of PowerPC cpu features
- Added RHEL-8.8 and 9.2 integration tests

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-07-27 15:02:33 -04:00
Joe Lawrence
efcf2ad187
Merge pull request #1349 from joe-lawrence/ppc64le-ftr-sections
kpatch-build: skip mangling for powerpc cpu feature relocations
2023-07-26 14:51:05 -04:00
Joe Lawrence
bcebb5206f test/unit: bump to latest
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-07-26 14:47:17 -04:00
Joe Lawrence
f58eaee1a1 kpatch-build: skip mangling for powerpc cpu feature relocations
PowerPC implements alternative instructions with __ftr_fixup and
__ftr_alt_* sections, for example net/core/dev.o:

  Disassembly of section __ftr_alt_97:

  0000000000000000 <__ftr_alt_97>:
     0: 3c 00 40 7c pause_short
     4: 3c 00 40 7c pause_short
     8: 3c 00 40 7c pause_short
     c: 3c 00 40 7c pause_short

  Disassembly of section __ftr_fixup:

  0000000000000000 <__ftr_fixup>:
     0: 00 00 00 00 .long 0x0
     4: 00 00 04 00 .long 0x40000
    ...
    10: R_PPC64_REL64 .text.napi_busy_loop+0x1cc
    18: R_PPC64_REL64 .text.napi_busy_loop+0x1dc
    20: R_PPC64_REL64 __ftr_alt_97+0x20
    28: R_PPC64_REL64 __ftr_alt_97+0x2c
    34: 00 00 04 00 .long 0x40000
    ...
    40: R_PPC64_REL64 .text.napi_busy_loop+0x3c0
    48: R_PPC64_REL64 .text.napi_busy_loop+0x3d0
    50: R_PPC64_REL64 __ftr_alt_97+0x24
    58: R_PPC64_REL64 __ftr_alt_97+0x30
    64: 00 00 04 00 .long 0x40000
    ...
    70: R_PPC64_REL64 .text.napi_threaded_poll+0x170
    78: R_PPC64_REL64 .text.napi_threaded_poll+0x180
    80: R_PPC64_REL64 __ftr_alt_97+0x28
    88: R_PPC64_REL64 __ftr_alt_97+0x34
    94: 00 00 04 00 .long 0x40000
    ...
    a0: R_PPC64_REL64 .text.net_rx_action+0x1a0
    a8: R_PPC64_REL64 .text.net_rx_action+0x1b0
    b0: R_PPC64_REL64 __ftr_alt_97+0x2c
    b8: R_PPC64_REL64 __ftr_alt_97+0x38

Like .altinstr_{aux,replacement}, __ftr_alt sections don't have symbols
associated with them and may skip kpatch_replace_sections_syms()'s rela
mangling.  As __ftr_fixup references __ftr_alt_* directly,
kpatch_process_special_sections() will already include __ftr_alt_* as
part of the "group" handling in kpatch_regenerate_special_section().

Reported-by: Zhijun Wang <zhijwang@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-07-26 14:46:21 -04:00
Josh Poimboeuf
960ceb278c
Merge pull request #1341 from jpoimboe/stale-workflow
github actions: Add stale workflow
2023-07-20 18:13:27 -05:00
Josh Poimboeuf
8a00d03bb8
Merge pull request #1346 from jpoimboe/locals-match-empty
lookup: skip duplicate local symbol table check for files without locals
2023-07-20 18:12:15 -05:00
Josh Poimboeuf
f8d2534210
Merge pull request #1339 from bhllamoreaux/photon-os-support
kpatch-build: support Photon OS distribution
2023-06-20 17:01:27 -07:00
Brennan Lamoreaux
758881bd5f kpatch-build: support for Photon OS
VMware's Photon OS uses kpatch to build kernel livepatches, starting with 3.0.

Add some changes to support Photon OS in kpatch, so we can use kpatch-build
in Photon like:
kpatch-build <name>.patch.

This commit integrates Photon OS support into existing kpatch-build support code
for various distros.
2023-06-05 22:08:03 +00:00
Josh Poimboeuf
75927e7bbb lookup: skip duplicate local symbol table check for files without locals
If the file doesn't have local object/func symbols, any empty match will
do, and duplicate matching local symbol lists aren't a problem.

Fixes #1345.

Reported-by: lzwycc <lzw32321226@163.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2023-06-05 09:49:30 -07:00
Joe Lawrence
94bcca58e1
Merge pull request #1343 from joe-lawrence/integration-tests-rhel-8.8
test/integration/rhel-8.8: add kernel-4.18.0-477.10.1.el8_8 tests
2023-05-16 15:52:39 -04:00
Joe Lawrence
248bdbcc71
Merge pull request #1344 from joe-lawrence/integration-tests-rhel-9.2
test/integration/rhel-9.2: add kernel-5.14.0-284.11.1.el9_2 tests
2023-05-16 15:52:21 -04:00
Joe Lawrence
6708da4044 test/integration/rhel-9.2: add kernel-5.14.0-284.11.1.el9_2 tests
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-05-10 14:38:39 -04:00
Joe Lawrence
df177e2fc5 test/integration/rhel-8.8: add kernel-4.18.0-477.10.1.el8_8 tests
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-05-10 14:36:46 -04:00
Joe Lawrence
4553c02438
Merge pull request #1342 from ryanbsull/install_md_update
INSTALL.md: update OpenEuler prereqs formatting
2023-05-09 17:23:46 -04:00
Ryan Sullivan
27d0a22c8a INSTALL.md: update OpenEuler prereqs formatting
Shrink the size of the sub-section header below the OpenEuler section,
reducing confusion as to what section that is a part of, as it is only
necessary for OpenEuler machines.

Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2023-05-09 14:46:58 -04:00
Josh Poimboeuf
b1809c1797
Merge pull request #1329 from sumanthkorikkar/s390-syscall-macro
kpatch-syscall: update syscall macros for s390
2023-04-18 18:42:17 -05:00
Josh Poimboeuf
65256d477e github actions: Add stale workflow
kpatch maintainers have limited time.  While we greatly appreciate all
of our contributors, unfortunately it's not uncommon for kpatch issues
and PRs to get ignored for years.

Add a github workflow which marks issues/PRs stale after 30/60 days, and
then closes them after an additional week of inactivity.  Anybody who
cares about a particular issue/PR is welcome to help keep it open by
stating their case in a comment.

The stale tag gets cleared by adding a comment to the issue/PR, or by
manually removing the stale tag.

An assignee can be added to a long-term issue/PR to prevent it from
getting marked stale.

The action (which adds/removes stale tags, adds comments, and closes
issues/PRs) runs daily at 10:00 UTC.

Suggested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2023-04-18 10:53:16 -07:00
Sumanth Korikkar
cc8e030641 kpatch-syscall: update syscall macros for s390
Since linux 'commit 2213d44e140f ("s390/syscalls: get rid of system call alias
functions")', s390 syscall wrappers are modified. Adjust it accordingly
for kpatch

Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
2023-04-17 17:45:30 +02:00
Josh Poimboeuf
73cdcb15ab
Merge pull request #1322 from joe-lawrence/v6.2-support
Upstream kernel v6.2 support
2023-04-14 16:17:28 -05:00
Josh Poimboeuf
f499fc25e0 test/integration: Updated module.patch for Linux 6.2
Yulia reported a bug with module.patch which can be seen with
CONFIG_PROVE_RCU:

  BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49
  in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 1053, name: grep
  preempt_count: 0, expected: 0
  RCU nest depth: 1, expected: 0
  2 locks held by grep/1053:
   #0: ffff8881079bf1a0 (&p->lock){+.+.}-{3:3}, at: seq_read_iter+0x55/0x460
   #1: ffffffff8275d620 (rcu_read_lock){....}-{1:2}, at: cache_seq_start_rcu+0x5/0x140 [sunrpc]
  CPU: 3 PID: 1053 Comm: grep Tainted: G           OE K    6.2.0 #57
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.1-2.fc37 04/01/2014
  Call Trace:
   <TASK>
   dump_stack_lvl+0x5b/0x77
   __might_resched.cold+0xff/0x13a
   cpus_read_lock+0x16/0xd0
   static_key_disable+0xe/0x20
   e_show+0x5b/0xd70 [livepatch_module]
   seq_read_iter+0x127/0x460
   seq_read+0xa3/0xd0
   proc_reg_read+0x52/0xa0
   vfs_read+0xc9/0x2f0
   ? __do_sys_newfstat+0x57/0x60
   ? lock_is_held_type+0xe8/0x140
   ksys_read+0x6c/0xf0
   do_syscall_64+0x37/0x90
   entry_SYSCALL_64_after_hwframe+0x72/0xdc
  RIP: 0033:0x7fbd314f7af0
  Code: b6 fe ff ff 48 8d 3d 2f 78 09 00 48 83 ec 08 e8 96 25 02 00 66 0f 1f 44 00 00 83 3d d9 db 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 7e e3 01 00 48 89 04 24
  RSP: 002b:00007ffcd6f1c708 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
  RAX: ffffffffffffffda RBX: 0000000000008000 RCX: 00007fbd314f7af0
  RDX: 0000000000008000 RSI: 0000563c751ea000 RDI: 0000000000000003
  RBP: 0000000000008000 R08: 0000000000009008 R09: 0000000000000000
  R10: 0000000000000000 R11: 0000000000000246 R12: 0000563c751ea000
  R13: 0000000000000003 R14: 0000000000000003 R15: 0000563c751ea000

The problem is that the patched module's seq_operations take an RCU read
lock before calling e_show(), which is patched to call
static_key_disable(), which can sleep.

Fix the issue by moving all the module test code to a different module
(xfs) which doesn't take an RCU lock.

Also enable the pr_debug() test and make the static branch test
unconditional since they're supported by newer kernels and this test is
for 6.2.

Reported-by: Yulia Kopkova <ykopkova@redhat.com>
Debugged-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2023-03-22 17:45:07 -07:00
Josh Poimboeuf
0dc10cad76
Merge pull request #1336 from jpoimboe/setlocalversion
kpatch-build: Fix setlocalversion issue with 6.3 kernel
2023-03-17 12:27:41 -05:00
Joe Lawrence
4df1528cd9 gcc-plugin: update gcc-common.h for gcc-13
Backport this kernel commit to kpatch's version of gcc-common.h:

commit e6a71160cc145e18ab45195abf89884112e02dfb
Author: Kees Cook <keescook@chromium.org>
Date:   Wed Jan 18 12:21:35 2023 -0800

    gcc-plugins: Reorganize gimple includes for GCC 13

    The gimple-iterator.h header must be included before gimple-fold.h
    starting with GCC 13. Reorganize gimple headers to work for all GCC
    versions.

    Reported-by: Palmer Dabbelt <palmer@rivosinc.com>
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
    Link: https://lore.kernel.org/all/20230113173033.4380-1-palmer@rivosinc.com/
    Cc: linux-hardening@vger.kernel.org
    Signed-off-by: Kees Cook <keescook@chromium.org>

Note that we can't directly copy the gcc-plugin headers from the kernel
as has it has dropped gcc-4.9 and older support since v5.16.  Distros
like rhel-7 still use gcc-4.8, so manually cherry pick changes into the
kpatch tree.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-03-16 22:05:43 -07:00
Joe Lawrence
3e54c63b17 create-diff-object: support x86 NOP-padded functions
Kernel v6.2+ commit bea75b33895f ("x86/Kconfig: Introduce function
padding") added 16 bytes of NOP padding in front of each function.

For objects built with --function-sections, this means that function
symbols no longer sit at the beginning of their respective ELF sections,
but 16 bytes offset.

In the same release, kernel v6.2+ commit 9f2899fe36a6 ("objtool: Add
option to generate prefix symbols") adds ELF function symbols with
prefix "__pfx_" to indicate the start of a function, inclusive of
NOP-padding.

For example:

  $ objdump -Dr -j.text.cmdline_proc_show fs/proc/cmdline.o
  ...
  Disassembly of section .text.cmdline_proc_show:

  0000000000000000 <__pfx_cmdline_proc_show>:
     0:   90                      nop
     1:   90                      nop
     2:   90                      nop
     3:   90                      nop
     4:   90                      nop
     5:   90                      nop
     6:   90                      nop
     7:   90                      nop
     8:   90                      nop
     9:   90                      nop
     a:   90                      nop
     b:   90                      nop
     c:   90                      nop
     d:   90                      nop
     e:   90                      nop
     f:   90                      nop

  0000000000000010 <cmdline_proc_show>:
    10:   e8 00 00 00 00          callq  15 <cmdline_proc_show+0x5>
                          11: R_X86_64_PLT32      __fentry__-0x4
    15:   55                      push   %rbp
    16:   48 8b 35 00 00 00 00    mov    0x0(%rip),%rsi        # 1d <cmdline_proc_show+0xd>
                          19: R_X86_64_PC32       saved_command_line-0x4
    1d:   48 89 fd                mov    %rdi,%rbp
    20:   e8 00 00 00 00          callq  25 <cmdline_proc_show+0x15>
                          21: R_X86_64_PLT32      seq_puts-0x4
    25:   48 89 ef                mov    %rbp,%rdi
    28:   be 0a 00 00 00          mov    $0xa,%esi
    2d:   e8 00 00 00 00          callq  32 <cmdline_proc_show+0x22>
                          2e: R_X86_64_PLT32      seq_putc-0x4
    32:   31 c0                   xor    %eax,%eax
    34:   5d                      pop    %rbp
    35:   e9 00 00 00 00          jmpq   3a <cmdline_proc_show+0x2a>
                          36: R_X86_64_PLT32      __x86_return_thunk-0x4

Kpatch-build needs to gracefully handle NOP-padding when it is present.
At the same time, it should include "__pfx_<function>" symbols when
their respective functions change, but not treat prefix such functions
as first-class functions.

This also adds support for CONFIG_CFI_CLANG, which also creates prefixed
symbols with the name "__cfi_<function>".

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2023-03-16 22:05:33 -07:00
Joe Lawrence
0d48a4357e test/integration: add upstream 6.2.0 patches
Add patches rebased on top of upstream 6.2.0.

Integration tests for these can be ran as this:

  $ make PATCH_DIR="linux-6.2.0" KPATCH_BUILD_OPTS="--non-replace --sourcedir /path/to/src/linux-6.2.0" integration-slow

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-03-15 15:26:37 -07:00
Joe Lawrence
2ddeccccb2 kpatch-elf: copy ELF e_flags from patched .o
Kernel v6.2+ commit de3d098dd1fc ("powerpc/64: Add module check for ELF
ABI version") now verifies the ELF header e_flags for its ABI value and
refuse to load modules with complaint, "Invalid module architecture in
ELF header: 21"

Like other ELF header details, copy the flags from the reference ELF
input file to the new ELF file to avoid module load errors.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-03-15 15:26:34 -07:00
Joe Lawrence
7d22fefa35 create-diff-object: ignore __patchable_function_entries
Kernel v6.2+ commit bea75b33895f ("x86/Kconfig: Introduce function
padding") introduces the -fpatchable-function-entry=16,16 build flag on
x86.  This leverages compiler support for generating a
__patchable_function_entries section similar to __mcount_loc.

That said, x86 still utilizes __mcount_loc even when
__patchable_function_entries exists.  The latter point to the __pfx
symbols, but the section is discarded in the vmlinux link and isn't used
regardless, for ftrace or for any other purpose.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2023-03-15 15:25:10 -07:00
Joe Lawrence
831a22bd1c
Merge pull request #1332 from sumanthkorikkar/ubsan-support
support ubsan for kpatch
2023-03-15 12:49:46 -04:00
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