Merge tag 'trace-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-block.git] / kernel / module.c
index 279a469dc375eb69ef6b9f512ece3769dd162aab..f0411a27176552a2a172c534a84c37e10c76705d 100644 (file)
@@ -278,6 +278,16 @@ static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE);
 module_param(sig_enforce, bool_enable_only, 0644);
 #endif /* !CONFIG_MODULE_SIG_FORCE */
 
+/*
+ * Export sig_enforce kernel cmdline parameter to allow other subsystems rely
+ * on that instead of directly to CONFIG_MODULE_SIG_FORCE config.
+ */
+bool is_module_sig_enforced(void)
+{
+       return sig_enforce;
+}
+EXPORT_SYMBOL(is_module_sig_enforced);
+
 /* Block module loading/unloading? */
 int modules_disabled = 0;
 core_param(nomodule, modules_disabled, bint, 0);
@@ -837,10 +847,8 @@ static int add_module_usage(struct module *a, struct module *b)
 
        pr_debug("Allocating new usage for %s.\n", a->name);
        use = kmalloc(sizeof(*use), GFP_ATOMIC);
-       if (!use) {
-               pr_warn("%s: out of memory loading\n", a->name);
+       if (!use)
                return -ENOMEM;
-       }
 
        use->source = a;
        use->target = b;
@@ -1516,7 +1524,7 @@ static void add_sect_attrs(struct module *mod, const struct load_info *info)
                sattr->mattr.show = module_sect_show;
                sattr->mattr.store = NULL;
                sattr->mattr.attr.name = sattr->name;
-               sattr->mattr.attr.mode = S_IRUGO;
+               sattr->mattr.attr.mode = S_IRUSR;
                *(gattr++) = &(sattr++)->mattr.attr;
        }
        *gattr = NULL;
@@ -4149,6 +4157,7 @@ static int m_show(struct seq_file *m, void *p)
 {
        struct module *mod = list_entry(p, struct module, list);
        char buf[MODULE_FLAGS_BUF_SIZE];
+       unsigned long value;
 
        /* We always ignore unformed modules. */
        if (mod->state == MODULE_STATE_UNFORMED)
@@ -4164,7 +4173,8 @@ static int m_show(struct seq_file *m, void *p)
                   mod->state == MODULE_STATE_COMING ? "Loading" :
                   "Live");
        /* Used by oprofile and other similar tools. */
-       seq_printf(m, " 0x%pK", mod->core_layout.base);
+       value = m->private ? 0 : (unsigned long)mod->core_layout.base;
+       seq_printf(m, " 0x" KALLSYM_FMT, value);
 
        /* Taints info */
        if (mod->taints)
@@ -4186,9 +4196,23 @@ static const struct seq_operations modules_op = {
        .show   = m_show
 };
 
+/*
+ * This also sets the "private" pointer to non-NULL if the
+ * kernel pointers should be hidden (so you can just test
+ * "m->private" to see if you should keep the values private).
+ *
+ * We use the same logic as for /proc/kallsyms.
+ */
 static int modules_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &modules_op);
+       int err = seq_open(file, &modules_op);
+
+       if (!err) {
+               struct seq_file *m = file->private_data;
+               m->private = kallsyms_show_value() ? NULL : (void *)8ul;
+       }
+
+       return 0;
 }
 
 static const struct file_operations proc_modules_operations = {