Commit Graph

2354 Commits

Author SHA1 Message Date
Joe Lawrence f1ce4791d2
Merge pull request #1400 from sumanthkorikkar/add-fpic-flag-s390
s390/kpatch-build: add -fPIC flag with -mno-pic-data-is-text-relative
2024-07-16 09:37:54 -04:00
Sumanth Korikkar 5695dce6de s390/kpatch-build: add -fPIE flag with -mno-pic-data-is-text-relative
-mno-pic-data-is-text-relative compiler flag expects -fPIC/-fPIE flag
along with it.  Since kernel commit 778666df60f0 ("s390: compile
relocatable kernel without -fPIE"), the -fPIC/-fPIE flag is missing when
creating kpatch module and this can lead to the following error:

cc1: error: ‘-mno-pic-data-is-text-relative’ cannot be used without
‘-fpic’/‘-fPIC’.

Previously kpatch-build didnt show up this issue, as the previous kernel
was built with -fPIE.

However, kpatch build could fail with kernel commit 778666df60f0 ("s390:
compile relocatable kernel without -fPIE"), where -fPIE is not included.
Hence, include it in kpatch-build for all kernels < 6.10.0

Note:
Latest s390 kernel is built with -fPIC flag.
i.e. kernel commit 00cda11d3b2e ("s390: Compile kernel with -fPIC and
link with -no-pie"). Hence, there is no need to explicitly add it again
in kpatch-build.

Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
2024-06-24 14:28:33 +02:00
Joe Lawrence 6457c4ccf9
Merge pull request #1396 from mihails-strasuns/al-id
Recognize Amazon Linux ID in kpatch-build
2024-06-06 10:23:22 -04:00
Puranjay Mohan 90a92f9492 Recognize Amazon Linux ID in kpatch-build
Make kpatch-build aware about the ID of Amazon Linux distributions. No
other special changes are needed.

Signed-off-by: Puranjay Mohan <pjy@amazon.com>
2024-06-05 12:08:36 +00:00
Joe Lawrence 09e153d3c9
Merge pull request #1394 from ZzzMao/rpm-spec
Fix formatting issue and date errors in spec file
2024-05-14 22:21:15 -04:00
Joe Lawrence bb93ac9c65
Merge pull request #1393 from joe-lawrence/ld-orphan-error
Fix builds with CONFIG_ERROR
2024-05-14 22:20:58 -04:00
Joe Lawrence b75d4c4449
Merge pull request #1392 from ryanbsull/x86-paravirt-fix
kpatch-build: handle paravirt absence in Linux v6.8+
2024-05-14 22:20:46 -04:00
Ziwei Mao 7e5eddc105 Update spec file
Fix formatting issue and date error
2024-05-10 17:27:55 +00:00
Joe Lawrence 69e71f8dcc kpatch-build: cleanup kernel file backup/restore
Temporarily editing kernel tree sources has become a recurring
requirement in kpatch-build.  Pull the saving/restoring of these files
into a common function helpers to standardize the pattern.

Reported-and-tested-by: Zhijun Wang <zhijwang@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-05-07 15:38:27 -04:00
Joe Lawrence 56dfdbeb5b kpatch-build: demote CONFIG_LD_ORPHAN_WARN_LEVEL
Upstream kernel v6.1+ commit linux@e1789d7c752e ("kbuild: upgrade the
orphan section warning to an error if CONFIG_WERROR is set") and
CONFIG_WERROR will result in failed kernel builds due to the linker
reporting tons of "unplaced orphan section `.text.<function>`
<object-file.o>" errors.

Workaround this by temporarily demoting such errors in the top-level
kernel Makefile.

Reported-and-tested-by: Zhijun Wang <zhijwang@redhat.com>
Closes: #1391 ("CONFIG_WERROR=y and CONFIG_LD_ORPHAN_WARN_LEVEL="error" break kpatch-build")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-05-07 15:34:03 -04:00
Ryan Sullivan 36ba2b8dfc kpatch-build: handle paravirt absence in Linux v6.8+
Upstream kernel commit f7af6977621a ("x86/paravirt: Remove no longer
needed paravirt patching code") v6.8+ removed the .parainstructions
section and its paravirt_patch_site struct. Therefore this checks the
kernel version and does not export the struct size if the kernel
version is >= v6.8.0, avoiding the code path for it in
create-diff-object.c entirely.

Fixes: https://github.com/dynup/kpatch/issues/1380

Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
2024-05-03 16:06:23 -04:00
Joe Lawrence ef68b4e416
Merge pull request #1383 from joe-lawrence/integration-dmesg-again
kpatch-test: add dmesg entry at start of test
2024-04-23 16:17:37 -04:00
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
Joe Lawrence 796872f9f3 kpatch-test: add dmesg entry at start of test
If the kernel log is empty prior to running the integration tests, the
following confusing status may be reported:

  ...
  ERROR: dmesg overflow, try increasing kernel log buffer size
  SUCCESS

This occurs because the script can't find an empty dmesg entry when the
tests are complete.  Copy the upstream kernel livepatching kselftests to
fix this by logging a canary message at the beginning of the integration
tests.  This will ensure a "real" message than can be found at the end.

Fixes: de1d0c6e08 ("kpatch-test: don't clear dmesg during test")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-03-25 17:12:53 -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