Monday, January 2, 2012

Disable Linux Kernel Version Magic problem while loading the module

Linux kernel will refuse to load kernel module, if the linux version magic is not match.

goto kernel/module.c file in kernel folder.

check for 'check_modinfo' function .

comment return -ENOEXEC this line in below function for same_magic() check.

static int check_modinfo(struct module *mod, struct load_info *info)
const char *modmagic = get_modinfo(info, "vermagic");
int err;

/* This is allowed: modprobe --force will invalidate it. */
if (!modmagic) {
err = try_to_force_load(mod, "bad vermagic");
if (err)
return err;
} else if (!same_magic(modmagic, vermagic, info->index.vers)) {
printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
mod->name, modmagic, vermagic);
return -ENOEXEC; }

if (get_modinfo(info, "staging")) {
add_taint_module(mod, TAINT_CRAP);
printk(KERN_WARNING "%s: module is from the staging directory,"
" the quality is unknown, you have been warned.\n",

/* Set up license info based on the info section */
set_license(mod, get_modinfo(info, "license"));

return 0;

1 comment: