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

Peter Senna Tschudin peter.senna at gmail.com
Tue Oct 16 11:32:17 EDT 2012


See what I've found:
http://www.kernel.org/pub/linux/kernel/people//akpm/patches/2.6/2.6.6-rc3/2.6.6-rc3-mm2/broken-out/proc-sys-kernel-vermagic.patch

On Tue, Oct 16, 2012 at 5:06 PM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
> 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
> ========================================================================
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
Peter



More information about the Kernelnewbies mailing list