fix kernel modules build after updating linux to v5.9.2

- `dep.c` and `dep2.c`: `debugfs_create_u32` does not return anymore, not
  sure why:
  https://unix.stackexchange.com/questions/593983/creating-a-debugfs-file-that-is-used-to-read-write-u32-value/621282#621282
  So just doing `debugfs_lookup` for now
- vermagic.c:
  51161bfc66
  prevents its usage in v5.8. Just migrating to `init_utsname` for now
- procfs.c: `struct file_operations` moved to a new `struct proc_ops` at:
  b567e07513
- myprintk.c: `pr_warning` dropped for `pr_warn`:
  61ff72f401
- `poll.c`: `kthread_func` is not defined in kernel, prefix with lkmc to
  avoid conflict

Fix https://github.com/cirosantilli/linux-kernel-module-cheat/issues/136

Fix https://github.com/cirosantilli/linux-kernel-module-cheat/issues/137
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-11-24 00:00:01 +00:00
parent fa8c2ee521
commit 50570326d4
9 changed files with 65 additions and 34 deletions

View File

@@ -6765,7 +6765,22 @@ Bibliography:
==== vermagic
Vermagic is a magic string present in the kernel and on <<module-info>> of kernel modules. It is used to verify that the kernel module was compiled against a compatible kernel version and relevant configuration:
link:kernel_modules/vermagic.c[]
As of kernel v5.8, you can't use `VERMAGIC_STRING` string from modules anymore as per: https://github.com/cirosantilli/linux/commit/51161bfc66a68d21f13d15a689b3ea7980457790[]. So instead we just showcase `init_utsname`.
Sample insmod output as of LKMC fa8c2ee521ea83a74a2300e7a3be9f9ab86e2cb6 + 1 aarch64:
....
<6>[ 25.180697] sysname = Linux
<6>[ 25.180697] nodename = buildroot
<6>[ 25.180697] release = 5.9.2
<6>[ 25.180697] version = #1 SMP Thu Jan 1 00:00:00 UTC 1970
<6>[ 25.180697] machine = aarch64
<6>[ 25.180697] domainname = (none)
....
Vermagic is a magic string present in the kernel and previously visible in <<module-info>> on kernel modules. It is used to verify that the kernel module was compiled against a compatible kernel version and relevant configuration:
....
insmod vermagic.ko
@@ -6777,8 +6792,6 @@ Possible dmesg output:
VERMAGIC_STRING = 4.17.0 SMP mod_unload modversions
....
Source: link:kernel_modules/vermagic.c[]
If we artificially create a mismatch with `MODULE_INFO(vermagic`, the insmod fails with:
....