]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/module.c
Merge tag 'libnvdimm-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
[karo-tx-linux.git] / kernel / module.c
index 7eba6dea4f417dbf363731cf2a3cc374ce1d703b..f37308b733d845526918588d2948673925e7ac5b 100644 (file)
@@ -665,16 +665,7 @@ static void percpu_modcopy(struct module *mod,
                memcpy(per_cpu_ptr(mod->percpu, cpu), from, size);
 }
 
-/**
- * is_module_percpu_address - test whether address is from module static percpu
- * @addr: address to test
- *
- * Test whether @addr belongs to module static percpu area.
- *
- * RETURNS:
- * %true if @addr is from module static percpu area
- */
-bool is_module_percpu_address(unsigned long addr)
+bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
 {
        struct module *mod;
        unsigned int cpu;
@@ -688,9 +679,15 @@ bool is_module_percpu_address(unsigned long addr)
                        continue;
                for_each_possible_cpu(cpu) {
                        void *start = per_cpu_ptr(mod->percpu, cpu);
-
-                       if ((void *)addr >= start &&
-                           (void *)addr < start + mod->percpu_size) {
+                       void *va = (void *)addr;
+
+                       if (va >= start && va < start + mod->percpu_size) {
+                               if (can_addr) {
+                                       *can_addr = (unsigned long) (va - start);
+                                       *can_addr += (unsigned long)
+                                               per_cpu_ptr(mod->percpu,
+                                                           get_boot_cpu_id());
+                               }
                                preempt_enable();
                                return true;
                        }
@@ -701,6 +698,20 @@ bool is_module_percpu_address(unsigned long addr)
        return false;
 }
 
+/**
+ * is_module_percpu_address - test whether address is from module static percpu
+ * @addr: address to test
+ *
+ * Test whether @addr belongs to module static percpu area.
+ *
+ * RETURNS:
+ * %true if @addr is from module static percpu area
+ */
+bool is_module_percpu_address(unsigned long addr)
+{
+       return __is_module_percpu_address(addr, NULL);
+}
+
 #else /* ... !CONFIG_SMP */
 
 static inline void __percpu *mod_percpu(struct module *mod)
@@ -732,6 +743,11 @@ bool is_module_percpu_address(unsigned long addr)
        return false;
 }
 
+bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
+{
+       return false;
+}
+
 #endif /* CONFIG_SMP */
 
 #define MODINFO_ATTR(field)    \
@@ -947,6 +963,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
                return -EFAULT;
        name[MODULE_NAME_LEN-1] = '\0';
 
+       audit_log_kern_module(name);
+
        if (mutex_lock_interruptible(&module_mutex) != 0)
                return -EINTR;
 
@@ -4017,7 +4035,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
 
        /* Don't lock: we're in enough trouble already. */
        preempt_disable();
-       if ((colon = strchr(name, ':')) != NULL) {
+       if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) {
                if ((mod = find_module_all(name, colon - name, false)) != NULL)
                        ret = mod_find_symname(mod, colon+1);
        } else {