any way to see the running kernel's "vermagic" string?

Robert P. J. Day rpjday at crashcourse.ca
Tue Oct 16 11:06:12 EDT 2012


On Tue, 16 Oct 2012, Chinmay V S wrote:

> Isn't "uname -r" on the console good enough?...

  no, the vermagic string is considerably more informative.  as i
mentioned, look at the definition in vermagic.h:

#define VERMAGIC_STRING                                                 \
        UTS_RELEASE " "                                                 \
        MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT                     \
        MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS       \
        MODULE_ARCH_VERMAGIC

that should (partially?) match the "vermagic" string you see with
modinfo, as in:

$ modinfo vfat
... snip ...
vermagic:       3.6.0-oct8+ SMP mod_unload modversions   <--- there!
$

  if you check the logic of module loading in kernel/module.c, you'll
see checks being made to see if the two strings are compatible, as in:

... snip ...
static const char vermagic[] = VERMAGIC_STRING;
... snip ...
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;
        }
... snip ...

  it's not that big a deal, but it would be informative to be able to
see the kernel's full vermagic string.

rday


-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the Kernelnewbies mailing list