Merge tag 'modules-for-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu...
[sfrench/cifs-2.6.git] / kernel / module.c
index 1e3337bcf1e708d43661febc49f98ccc1e535d78..f475f30eed8c031abc5e88241ee5088056dbb664 100644 (file)
@@ -1470,7 +1470,8 @@ static ssize_t module_sect_show(struct module_attribute *mattr,
 {
        struct module_sect_attr *sattr =
                container_of(mattr, struct module_sect_attr, mattr);
-       return sprintf(buf, "0x%pK\n", (void *)sattr->address);
+       return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
+                      (void *)sattr->address : NULL);
 }
 
 static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
@@ -1601,8 +1602,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
        if (notes == 0)
                return;
 
-       notes_attrs = kzalloc(sizeof(*notes_attrs)
-                             + notes * sizeof(notes_attrs->attrs[0]),
+       notes_attrs = kzalloc(struct_size(notes_attrs, attrs, notes),
                              GFP_KERNEL);
        if (notes_attrs == NULL)
                return;
@@ -3514,6 +3514,11 @@ static noinline int do_init_module(struct module *mod)
         * walking this with preempt disabled.  In all the failure paths, we
         * call synchronize_sched(), but we don't want to slow down the success
         * path, so use actual RCU here.
+        * Note that module_alloc() on most architectures creates W+X page
+        * mappings which won't be cleaned up until do_free_init() runs.  Any
+        * code such as mark_rodata_ro() which depends on those mappings to
+        * be cleaned up needs to sync with the queued work - ie
+        * rcu_barrier_sched()
         */
        call_rcu_sched(&freeinit->rcu, do_free_init);
        mutex_unlock(&module_mutex);