module: include other structures in module version check
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 19:05:34 +0000 (13:05 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 02:35:34 +0000 (13:05 +1030)
With CONFIG_MODVERSIONS, we version 'struct module' using a dummy
export, but other things matter too:

1) 'struct modversion_info' determines the layout of the __versions section,
2) 'struct kernel_param' determines the layout of the __params section,
3) 'struct kernel_symbol' determines __ksymtab*.
4) 'struct marker' determines __markers.
5) 'struct tracepoint' determines __tracepoints.

So we rename 'struct_module' to 'module_layout' and include these in
the signature.  Now it's general we can add others later on without
confusion.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
kernel/module.c
scripts/mod/modpost.c

index 784bf6d8f8c4c1deb76ab3e33f3dccd214250570..e8cf636e614bafbd773397fcae32830291ae44bd 100644 (file)
@@ -1052,9 +1052,9 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
 {
        const unsigned long *crc;
 
-       if (!find_symbol("struct_module", NULL, &crc, true, false))
+       if (!find_symbol("module_layout", NULL, &crc, true, false))
                BUG();
-       return check_version(sechdrs, versindex, "struct_module", mod, crc);
+       return check_version(sechdrs, versindex, "module_layout", mod, crc);
 }
 
 /* First part is kernel version, which we ignore if module has crcs. */
@@ -2858,9 +2858,17 @@ void print_modules(void)
 }
 
 #ifdef CONFIG_MODVERSIONS
-/* Generate the signature for struct module here, too, for modversions. */
-void struct_module(struct module *mod) { return; }
-EXPORT_SYMBOL(struct_module);
+/* Generate the signature for all relevant module structures here.
+ * If these change, we don't want to try to parse the module. */
+void module_layout(struct module *mod,
+                  struct modversion_info *ver,
+                  struct kernel_param *kp,
+                  struct kernel_symbol *ks,
+                  struct marker *marker,
+                  struct tracepoint *tp)
+{
+}
+EXPORT_SYMBOL(module_layout);
 #endif
 
 #ifdef CONFIG_MARKERS
index 7e62303133dc68e16eb3b1457068cdf52b5db1d2..8cc70612984c11a392815e6d79ff94e5ec7a1fc2 100644 (file)
@@ -1607,12 +1607,12 @@ static void read_symbols(char *modname)
 
        parse_elf_finish(&info);
 
-       /* Our trick to get versioning for struct_module - it's
+       /* Our trick to get versioning for module struct etc. - it's
         * never passed as an argument to an exported function, so
         * the automatic versioning doesn't pick it up, but it's really
         * important anyhow */
        if (modversions)
-               mod->unres = alloc_symbol("struct_module", 0, mod->unres);
+               mod->unres = alloc_symbol("module_layout", 0, mod->unres);
 }
 
 #define SZ 500