Less converstaion

This commit is contained in:
Ciro Santilli
2017-11-13 14:25:24 +00:00
parent 9ec43c4e88
commit fa0a7e150d
10 changed files with 116 additions and 250 deletions

View File

@@ -6,7 +6,10 @@
1. [hello](hello.c)
1. [hello2](hello2.c)
1. [panic](panic.c)
1. [params](params.c)
1. Module utils
1. [params](params.c)
1. [vermagic](vermagic.c)
1. [vermagic_fail](vermagic_fail.c)
1. Pseudo filesystems
1. [debugfs](debugfs.c)
1. [procfs](procfs.c)

21
kernel_module/vermagic.c Normal file
View File

@@ -0,0 +1,21 @@
/*
insmod /vermagic.ko
# => 4.9.6 SMP mod_unload modversions
TODO how to get the vermagic from running kernel from userland? <https://lists.kernelnewbies.org/pipermail/kernelnewbies/2012-October/006306.html>
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/vermagic.h>
static int myinit(void)
{
pr_info(VERMAGIC_STRING "\n");
return 0;
}
static void myexit(void) {}
module_init(myinit)
module_exit(myexit)
MODULE_LICENSE("GPL");

View File

@@ -0,0 +1,30 @@
/*
insmod /vermagic_fail.ko
# => insmod: can't insert '/vermagic_fail.ko': invalid module format
modinfo /vermagic_fail.ko | grep vermagic
# => vermagic: asdfqwer
# => vermagic: 4.9.6 SMP mod_unload modversions
kmod `modprobe` has a flag to skip the check:
--force-modversion
Looks like it just strips `modversion` information from the module before loading, and then the kernel skips the check.
*/
#include <linux/module.h>
#include <linux/kernel.h>
static int myinit(void)
{
pr_info("vermagic_fail\n");
return 0;
}
static void myexit(void) {}
module_init(myinit)
module_exit(myexit)
MODULE_INFO(vermagic, "asdfqwer");
MODULE_LICENSE("GPL");