vermagic_fail.c 686 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. insmod /vermagic_fail.ko
  3. # => insmod: can't insert '/vermagic_fail.ko': invalid module format
  4. modinfo /vermagic_fail.ko | grep vermagic
  5. # => vermagic: asdfqwer
  6. # => vermagic: 4.9.6 SMP mod_unload modversions
  7. kmod `modprobe` has a flag to skip the check:
  8. --force-modversion
  9. Looks like it just strips `modversion` information from the module before loading, and then the kernel skips the check.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. static int myinit(void)
  14. {
  15. pr_info("vermagic_fail\n");
  16. return 0;
  17. }
  18. static void myexit(void) {}
  19. module_init(myinit)
  20. module_exit(myexit)
  21. MODULE_INFO(vermagic, "asdfqwer");
  22. MODULE_LICENSE("GPL");