Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

livepatch/klp-build: Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL

When building a patch to a single-file kernel module with
CONFIG_MODULE_SRCVERSION_ALL enabled, the klp-build module link fails in
modpost:

Diffing objects
drivers/md/raid0.o: changed function: raid0_run
Building patch module: livepatch-0001-patch-raid0_run.ko
drivers/md/raid0.c: No such file or directory
...

The problem here is that klp-build copied drivers/md/.raid0.o.cmd to the
module build directory, but it didn't also copy over the input source
file listed in the .cmd file:

source_drivers/md/raid0.o := drivers/md/raid0.c

So modpost dies due to the missing .c file which is needed for
calculating checksums for CONFIG_MODULE_SRCVERSION_ALL.

Instead of copying the original .cmd file, just create an empty one.
Modpost only requires that it exists. The original object's build
dependencies are irrelevant for the frankenobjects used by klp-build.

Fixes: 24ebfcd65a87 ("livepatch/klp-build: Introduce klp-build script for generating livepatch modules")
Reported-by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/c41b6629e02775e4c1015259aa36065b3fe2f0f3.1769471792.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+4 -4
+4 -4
scripts/livepatch/klp-build
··· 555 555 local file_dir="$(dirname "$file")" 556 556 local orig_file="$ORIG_DIR/$rel_file" 557 557 local orig_dir="$(dirname "$orig_file")" 558 - local cmd_file="$file_dir/.$(basename "$file").cmd" 559 558 560 559 [[ ! -f "$file" ]] && die "missing $(basename "$file") for $_file" 561 560 562 561 mkdir -p "$orig_dir" 563 562 cp -f "$file" "$orig_dir" 564 - [[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$orig_dir" 565 563 done 566 564 xtrace_restore 567 565 ··· 738 740 local orig_dir="$(dirname "$orig_file")" 739 741 local kmod_file="$KMOD_DIR/$rel_file" 740 742 local kmod_dir="$(dirname "$kmod_file")" 741 - local cmd_file="$orig_dir/.$(basename "$file").cmd" 743 + local cmd_file="$kmod_dir/.$(basename "$file").cmd" 742 744 743 745 mkdir -p "$kmod_dir" 744 746 cp -f "$file" "$kmod_dir" 745 - [[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$kmod_dir" 746 747 747 748 # Tell kbuild this is a prebuilt object 748 749 cp -f "$file" "${kmod_file}_shipped" 750 + 751 + # Make modpost happy 752 + touch "$cmd_file" 749 753 750 754 echo -n " $rel_file" >> "$makefile" 751 755 done