Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small upstream kernel fixes #1397

Merged
merged 4 commits into from
Jul 18, 2024

Conversation

joe-lawrence
Copy link
Contributor

Three minor fix-ups for kpatch-build and upstream kernel trees:

  1. The supported_{deb,rpm}_distro() functions are now called when running with USERSRCDIR. Protect against indexing their associated arrays with empty strings
  2. Set the correct VMLINUX path when USERSRCDIR is specified ($TEMPDIR vs. $KERNEL_BACKUPDIR)
  3. Fix setlocalversion for pre-v6.3 kernels - we fixed this for newer kernels, but sometimes it's handy to run tests against older kernels... it's not too difficult to support both pre and post v6.3 kernels here.

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 <[email protected]>
Commit 69e71f8 ("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: 69e71f8 ("kpatch-build: cleanup kernel file backup/restore")
Signed-off-by: Joe Lawrence <[email protected]>
Commit 629b5ac ("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: 629b5ac ("kpatch-build: Fix setlocalversion issue with 6.3 kernel")
Signed-off-by: Joe Lawrence <[email protected]>
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: 629b5ac ("kpatch-build: Fix setlocalversion issue with 6.3 kernel")
Signed-off-by: Joe Lawrence <[email protected]>
@joe-lawrence joe-lawrence changed the title Draft: Small upstream kernel fixes Small upstream kernel fixes Jun 25, 2024
@joe-lawrence
Copy link
Contributor Author

@jpoimboe , @yhcote , @ryanbsull : can I get a quick review on this MR? Thanks.

@joe-lawrence joe-lawrence merged commit 6115a1a into dynup:master Jul 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants