lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 7 Mar 2012 14:57:21 +0000
From:	"Chen, Dennis (SRDC SW)" <Dennis1.Chen@....com>
To:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:	"Chen, Dennis (SRDC SW)" <Dennis1.Chen@....com>
Subject: [PATCH 2/2] Refine mutex and rcu method in module.c, kernel<3.2.9>

1. Add protection code for module_bug_list readers
2. Add a new module_bug_mutex as the mutex of the module_bug_list writers

--- bug.ori.c   2012-03-07 20:42:56.454850872 +0800
+++ bug.c       2012-03-07 20:58:48.562825887 +0800
@@ -42,6 +42,7 @@
 #include <linux/kernel.h>
 #include <linux/bug.h>
 #include <linux/sched.h>
+#include <linux/rcupdate.h>
 
 extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
 
@@ -56,19 +57,24 @@
 
 #ifdef CONFIG_MODULES
 static LIST_HEAD(module_bug_list);
+static DEFINE_MUTEX(module_bug_mutex);
 
 static const struct bug_entry *module_find_bug(unsigned long bugaddr)
 {
        struct module *mod;
 
-       list_for_each_entry(mod, &module_bug_list, bug_list) {
+       rcu_read_lock();
+       list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
                const struct bug_entry *bug = mod->bug_table;
                unsigned i;
 
                for (i = 0; i < mod->num_bugs; ++i, ++bug)
-                       if (bugaddr == bug_addr(bug))
+                       if (bugaddr == bug_addr(bug)){
+                               rcu_read_unlock();
                                return bug;
+                        }
        }
+       rcu_read_unlock();
        return NULL;
 }
 
@@ -96,7 +102,9 @@
         * traversals, but since we only traverse on BUG()s, a spinlock
         * could potentially lead to deadlock and thus be counter-productive.
         */
-       list_add(&mod->bug_list, &module_bug_list);
+       mutex_lock(&module_bug_mutex);
+       list_add_rcu(&mod->bug_list, &module_bug_list);
+       mutex_unlock(&module_bug_mutex);
 }
 
 void module_bug_cleanup(struct module *mod)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ