On 31.03.2017 20:39, Joe Lawrence wrote:
On 03/30/2017 08:11 PM, sam wrote:
On Thu, Mar 30, 2017 at 01:46:19PM -0400, Joe Lawrence wrote:
On 03/30/2017 12:16 PM, sam wrote:
Hi All,
Here is an issue:

root@sm-machine:/home/sam/Downloads/linux-4.8# kpatch load kpatch-2.ko
loading patch module: kpatch-2.ko
insmod: ERROR: could not insert module kpatch-2.ko: Invalid module
format
kpatch: failed to load module kpatch-2.ko


The patch file as follows:
--- ./fs/proc/meminfo.c 2017-03-31 00:00:23.558772349 +0800
+++ ../linux-4.8_ori/fs/proc/meminfo.c  2017-03-30 00:22:06.113318048
+0800
@@ -54,7 +54,7 @@
* Tagged format, for easy grepping and expansion.
*/
seq_printf(m,
         -               "SamMemTotal:       %8lu kB\n"
         +               "MemTotal:       %8lu kB\n"

This patch looks backwards... shouldn't it be changing "MemTotal" to
"SamMemTotal"?

Here is the message from dmesg when I run "kpatch load kpatch-2.ko":
[29769.346303] kpatch_2: disagrees about version of symbol module_layout

That usually indicates that vmlinux isn't what kpatch-build thinks it is.

And here is the process that I generate kpatch-2.ko:
***************
#!/bin/bash
#echo "[the modified  file] [ the original file ] [ patch file ]"
diff -u $1 $2  > $3
kpatch-build -s .  -v ./vmlinux  -t vmlinux --skip-gcc-check $3
*******
Here is the modinfo output:

root@sm-machine:/home/sam/Downloads/linux-4.8# modinfo kpatch-2.ko
filename:       /home/sam/Downloads/linux-4.8/kpatch-2.ko
livepatch:      Y
license:        GPL
depends:
vermagic:       4.8.0 SMP mod_unload modversions
root@sm-machine:/home/sam/Downloads/linux-4.8#

I think somehow the vmlinux you are pointing kpatch-build to is not the
same as the one that you are currently running.

I stumbled upon a probably similar problem some time ago when I tried to build a patch for the Ubuntu kernel 4.4.0-21-generic or so and used the tarball from their linux-source-* deb package to get the kernel sources.

IIRC, the patch module had vermagic "4.4.0 SMP <...>" as a result and the kernel refused to load it because "4.4.0" != "4.4.0-21-generic".

As a workaround, I changed the main kernel Makefile in linux-source-* so that version 4.4.0 was specified there and EXTRAVERSION was set to "-21-generic". Then I rebuilt the patch and it was loaded OK this time.

Not sure if it is the same problem here, but I hope this helps.


Can you extract a refreshed kernel build / tree and try again?  Also
fixup 2.patch accordingly.

Thanks,

-- Joe

Regards,
Evgenii

_______________________________________________
kpatch mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/kpatch

Reply via email to