When invoking kpatch-build through integration testing, like:
$ make PATCH_DIR="linux-6.9.0" \
KPATCH_BUILD_OPTS="--sourcedir /root/linux" \
integration-slow
results in an error as kpatch-build's `make kernelversion` adds
directory information to its output:
make[2]: Entering directory '/root/linux'
6.9.0
make[2]: Leaving directory '/root/linux'
This screws up kpatch-build's assignment of the make output to
LOCALVERSION, which was expecting only "6.9.0".
Add --no-print-directory to the make invocation to avoid the undesired
entering / leaving directory info.
Fixes: 629b5acf3d ("kpatch-build: Fix setlocalversion issue with 6.3 kernel")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Commit 629b5acf3d ("kpatch-build: Fix setlocalversion issue with 6.3
kernel") fixed VERMAGIC_STRING between kpatch original/patched kernel
builds by creating a temporary scripts/setlocalversion script. This was
accomplished by saving the output from `make kernelversion` into a
KERNELVERSION environment variable and running the (original)
scripts/setlocalversion to gather a "vX.Y" + "<src version>" pair of
strings.
Unfortunately pre-v6.3 scripts/setlocalversion does not use the
KERNELVERSION environment variable, so the same efforts results in an
unusable "<NULL>" + "<src version>" version string pair.
Restore the original `scripts/setlocalversion --save-scmversion`
invocation for source trees that (still) support the --save-scmversion
option.
Fixes: 629b5acf3d ("kpatch-build: Fix setlocalversion issue with 6.3 kernel")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Commit 69e71f8dcc ("kpatch-build: cleanup kernel file backup/restore")
consolidated a bunch of kernel-tree copy and restoring. As part of that
effort, when kpatch-build is invoked with a -s|--sourcedir USERSRCDIR
value the vmlinux file is now saved to "$TEMPDIR/kernel-backup/" and not
simply "$TEMPDIR/". This results in kpatch-build confusion like:
readelf: /home/jolawren/.kpatch/tmp/vmlinux: Error: No such file
Update the VMLINUX reassignment in this case to point to the new path.
Fixes: 69e71f8dcc ("kpatch-build: cleanup kernel file backup/restore")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
When kpatch-build is invoked with a -s|--sourcedir USERSRCDIR value,
kpatch-build doesn't source the /etc/os-release file as it can't assume
that the user-specified kernel source config matches any particular
distribution. Subsequent is_supported_{rpm,deb}_distro() function calls
will result in ugly syntax errors like:
kpatch-build: line 697: SUPPORTED_RPM_DISTROS: bad array subscript
kpatch-build: line 692: SUPPORTED_DEB_DISTROS: bad array subscript
Enhance the is_supported_{rpm,deb}_distro() functions to check that a
non-NULL distribution string argument exists before indexing the
SUPPORTED_{RPM,DEB}_DISTROS associative arrays.
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>