dynup/kpatch

kpatch load can't find core module

hongwentakkk opened this issue · 8 comments

kernel: 4.19.113.300.el7.x86_64

image

unable to find Module.symvers , Manual operation:
mkdir -p /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/
cp /root/kpatch/kmod/core/kpatch.ko /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/
cp /root/kpatch/kmod/core/Module.symvers /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/

kpatch-meminfo-string.ko

image

Module.symvers for kpatch.ko is needed for building the patch rather than for loading it.

So could you try to build the binary patch again, after you have copied /root/kpatch/kmod/core/Module.symvers to /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/?

Will kpatch-build complain now about Module.symvers?

Besides, please show the output of /sbin/modinfo /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/kpatch.ko, let us see the kernel kpatch.ko was built for.

By the way, which version of kpatch sources are you using to build kpatch.ko and the kpatch build tools? The latest revision from this git repo? Or some of the released versions?

image

The problem is solved in the following way
mkdir -p /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/
ln -s /usr/src/kernel/4.19.113-300.el7.x86_64/Module.symvers /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/

why Directory /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/ will not be created automatically,need to be created manually?

Under normal conditions , need to exist

/usr/local/lib/kpatch/4.19.113-300.el7.x86_64/Module.symvers and /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/kpatch.ko

image

It is really strange. Module.symvers is only used for building, it does not affect loading of the patch.

And, /usr/src/kernel/4.19.113-300.el7.x86_64/Module.symvers is the symvers file for the kernel, not for kpatch.ko. It is unrelated.

Also, please see my comment #1285 (comment), it might help build patches in a more reliable way.

image

Module.symvers is only used for building ,building error: not find Module.symvers;

loading of the patch error reson : not insert mod kpatch.ko ;insmod /root/kpatch/kmod/core/kpatch.ko is ok

The cause of the problem has been solved, thank you !

why Directory /usr/local/lib/kpatch/4.19.113-300.el7.x86_64/ will not be created automatically,need to be created manually?

This should not be necessary. The patch module you have built, kpatch-meminfo-string.ko either requires kpatch.ko or does not. modinfo path/to/kpatch-meminfo-string.ko should tell that.

  • If kpatch-meminfo-string.ko does not actually need kpatch.ko, then kpatch-build should not try to load kpatch.ko. If it does, it looks like a bug.

  • If kpatch-meminfo-string.ko depends on kpatch.ko, kpatch load would try to find kpatch.ko in specific locations, see find_core_module in kpatch script:

find_core_module() {
	COREMOD="$SCRIPTDIR"/../kmod/core/kpatch.ko
	[[ -f "$COREMOD" ]] && return

	COREMOD="/usr/local/lib/kpatch/$(uname -r)/kpatch.ko"
	[[ -f "$COREMOD" ]] && return

	COREMOD="/usr/lib/kpatch/$(uname -r)/kpatch.ko"
	[[ -f "$COREMOD" ]] && return

	COREMOD="/usr/local/lib/modules/$(uname -r)/extra/kpatch/kpatch.ko"
	[[ -f "$COREMOD" ]] && return

	COREMOD="/usr/lib/modules/$(uname -r)/extra/kpatch/kpatch.ko"
	[[ -f "$COREMOD" ]] && return

	return 1
}

You can place kpatch.ko in any of these locations. If the chosen directories do not exist, then yes, it is up to you to create them.

insmod /root/kpatch/kmod/core/kpatch.ko is ok

Ah, yes, if you have kpatch.ko in a non-standard location, then yes, loading it manually should help.

Glad it works for you now.