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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 31 Oct 2017 11:28:48 +0900
From:   Masahiro Yamada <yamada.masahiro@...ionext.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        "Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] genirq: add mutex and rcu locking to irq_desc_tree

Add a mutex to prevent concurrency on the updater side of the
irq_desc radix tree.

Add rcu_read_lock/unlock to the reader side so that lifetimes of
leaf pointers of the radix tree are correctly managed.

Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
---

 kernel/irq/irqdesc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 82afb7e..928c896 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -12,6 +12,7 @@
 #include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
+#include <linux/mutex.h>
 #include <linux/radix-tree.h>
 #include <linux/bitmap.h>
 #include <linux/irqdomain.h>
@@ -312,21 +313,32 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc) {}
 #endif /* CONFIG_SYSFS */
 
 static RADIX_TREE(irq_desc_tree, GFP_KERNEL);
+static DEFINE_MUTEX(irq_desc_tree_mutex);
 
 static void irq_insert_desc(unsigned int irq, struct irq_desc *desc)
 {
+	mutex_lock(&irq_desc_tree_mutex);
 	radix_tree_insert(&irq_desc_tree, irq, desc);
+	mutex_unlock(&irq_desc_tree_mutex);
 }
 
 struct irq_desc *irq_to_desc(unsigned int irq)
 {
-	return radix_tree_lookup(&irq_desc_tree, irq);
+	struct irq_desc *desc;
+
+	rcu_read_lock();
+	desc = radix_tree_lookup(&irq_desc_tree, irq);
+	rcu_read_unlock();
+
+	return desc;
 }
 EXPORT_SYMBOL(irq_to_desc);
 
 static void delete_irq_desc(unsigned int irq)
 {
+	mutex_lock(&irq_desc_tree_mutex);
 	radix_tree_delete(&irq_desc_tree, irq);
+	mutex_unlock(&irq_desc_tree_mutex);
 }
 
 #ifdef CONFIG_SMP
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ