Merge branch 'tracing-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[safe/jmp/linux-2.6] / kernel / module.c
index 7576c2d..0d8d21e 100644 (file)
@@ -102,7 +102,7 @@ static inline int strong_try_module_get(struct module *mod)
 static inline void add_taint_module(struct module *mod, unsigned flag)
 {
        add_taint(flag);
-       mod->taints |= flag;
+       mod->taints |= (1U << flag);
 }
 
 /*
@@ -786,6 +786,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
        mutex_lock(&module_mutex);
        /* Store the name of the last unloaded module for diagnostic purposes */
        strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
+       unregister_dynamic_debug_module(mod->name);
        free_module(mod);
 
  out:
@@ -925,7 +926,7 @@ static const char vermagic[] = VERMAGIC_STRING;
 static int try_to_force_load(struct module *mod, const char *symname)
 {
 #ifdef CONFIG_MODULE_FORCE_LOAD
-       if (!(tainted & TAINT_FORCED_MODULE))
+       if (!test_taint(TAINT_FORCED_MODULE))
                printk("%s: no version for \"%s\" found: kernel tainted.\n",
                       mod->name, symname);
        add_taint_module(mod, TAINT_FORCED_MODULE);
@@ -1035,7 +1036,7 @@ static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
        const unsigned long *crc;
 
        ret = find_symbol(name, &owner, &crc,
-                         !(mod->taints & TAINT_PROPRIETARY_MODULE), true);
+                         !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
        if (!IS_ERR_VALUE(ret)) {
                /* use_module can fail due to OOM,
                   or module initialization or unloading */
@@ -1175,7 +1176,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
                while (i-- > 0)
                        sysfs_remove_bin_file(notes_attrs->dir,
                                              &notes_attrs->attrs[i]);
-               kobject_del(notes_attrs->dir);
+               kobject_put(notes_attrs->dir);
        }
        kfree(notes_attrs);
 }
@@ -1639,7 +1640,7 @@ static void set_license(struct module *mod, const char *license)
                license = "unspecified";
 
        if (!license_is_gpl_compatible(license)) {
-               if (!(tainted & TAINT_PROPRIETARY_MODULE))
+               if (!test_taint(TAINT_PROPRIETARY_MODULE))
                        printk(KERN_WARNING "%s: module license '%s' taints "
                                "kernel.\n", mod->name, license);
                add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
@@ -1788,6 +1789,33 @@ static inline void add_kallsyms(struct module *mod,
 }
 #endif /* CONFIG_KALLSYMS */
 
+#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG
+static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex)
+{
+       struct mod_debug *debug_info;
+       unsigned long pos, end;
+       unsigned int num_verbose;
+
+       pos = sechdrs[verboseindex].sh_addr;
+       num_verbose = sechdrs[verboseindex].sh_size /
+                               sizeof(struct mod_debug);
+       end = pos + (num_verbose * sizeof(struct mod_debug));
+
+       for (; pos < end; pos += sizeof(struct mod_debug)) {
+               debug_info = (struct mod_debug *)pos;
+               register_dynamic_debug_module(debug_info->modname,
+                       debug_info->type, debug_info->logical_modname,
+                       debug_info->flag_names, debug_info->hash,
+                       debug_info->hash2);
+       }
+}
+#else
+static inline void dynamic_printk_setup(Elf_Shdr *sechdrs,
+                                       unsigned int verboseindex)
+{
+}
+#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */
+
 static void *module_alloc_update_bounds(unsigned long size)
 {
        void *ret = module_alloc(size);
@@ -1811,6 +1839,7 @@ static noinline struct module *load_module(void __user *umod,
        Elf_Ehdr *hdr;
        Elf_Shdr *sechdrs;
        char *secstrings, *args, *modmagic, *strtab = NULL;
+       char *staging;
        unsigned int i;
        unsigned int symindex = 0;
        unsigned int strindex = 0;
@@ -1836,6 +1865,7 @@ static noinline struct module *load_module(void __user *umod,
 #endif
        unsigned int markersindex;
        unsigned int markersstringsindex;
+       unsigned int verboseindex;
        unsigned int tracepointsindex;
        unsigned int tracepointsstringsindex;
        unsigned int mcountindex;
@@ -1969,6 +1999,14 @@ static noinline struct module *load_module(void __user *umod,
                goto free_hdr;
        }
 
+       staging = get_modinfo(sechdrs, infoindex, "staging");
+       if (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",
+                      mod->name);
+       }
+
        /* Now copy in args */
        args = strndup_user(uargs, ~0UL >> 1);
        if (IS_ERR(args)) {
@@ -2126,6 +2164,7 @@ static noinline struct module *load_module(void __user *umod,
        markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
        markersstringsindex = find_sec(hdr, sechdrs, secstrings,
                                        "__markers_strings");
+       verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose");
        tracepointsindex = find_sec(hdr, sechdrs, secstrings, "__tracepoints");
        tracepointsstringsindex = find_sec(hdr, sechdrs, secstrings,
                                        "__tracepoints_strings");
@@ -2188,6 +2227,7 @@ static noinline struct module *load_module(void __user *umod,
                marker_update_probe_range(mod->markers,
                        mod->markers + mod->num_markers);
 #endif
+       dynamic_printk_setup(sechdrs, verboseindex);
 #ifdef CONFIG_TRACEPOINTS
                tracepoint_update_probe_range(mod->tracepoints,
                        mod->tracepoints + mod->num_tracepoints);
@@ -2584,10 +2624,12 @@ static char *module_flags(struct module *mod, char *buf)
            mod->state == MODULE_STATE_GOING ||
            mod->state == MODULE_STATE_COMING) {
                buf[bx++] = '(';
-               if (mod->taints & TAINT_PROPRIETARY_MODULE)
+               if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE))
                        buf[bx++] = 'P';
-               if (mod->taints & TAINT_FORCED_MODULE)
+               if (mod->taints & (1 << TAINT_FORCED_MODULE))
                        buf[bx++] = 'F';
+               if (mod->taints & (1 << TAINT_CRAP))
+                       buf[bx++] = 'C';
                /*
                 * TAINT_FORCED_RMMOD: could be added.
                 * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't