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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 31 Jul 2015 19:08:06 +0200
From:	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	linux-kernel@...r.kernel.org,
	Rusty Russell <rusty@...tcorp.com.au>,
	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@...el.com>,
	tglx@...utronix.de,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [RFC 2/4] jump_label: use rcu_read_lock() while accessing __module_*()

__jump_label_mod_text_reserved() should most likely use rcu_read_lock()
while invoking __module_text_address(). I'm not sure there is anything
to protect the module pointed by `start' and `end' from removal.
I *think* the protection is based on the preempt_disable() in
check_kprobe_address_safe(). That preempt_disable however does not
protect from module removal on a SMP machine.

Same goes for jump_label_update(). I think it is safe here to avoid the
read lock since the caller is the module so it can't go away at the same
time. However it might get a problem if the key reference here is shared
across modules for some reason with no module dependency.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
 kernel/jump_label.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 52ebaca1b9fc..8aa9e0fce92e 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -231,16 +231,21 @@ struct static_key_mod {
 static int __jump_label_mod_text_reserved(void *start, void *end)
 {
 	struct module *mod;
+	int ret = 0;
 
+	rcu_read_lock();
 	mod = __module_text_address((unsigned long)start);
 	if (!mod)
-		return 0;
+		goto out;
 
 	WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
 
-	return __jump_label_text_reserved(mod->jump_entries,
+	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
 				start, end);
+out:
+	rcu_read_unlock();
+	return ret;
 }
 
 static void __jump_label_mod_update(struct static_key *key, int enable)
@@ -448,11 +453,11 @@ static void jump_label_update(struct static_key *key, int enable)
 
 	__jump_label_mod_update(key, enable);
 
-	preempt_disable();
+	rcu_read_lock();
 	mod = __module_address((unsigned long)key);
 	if (mod)
 		stop = mod->jump_entries + mod->num_jump_entries;
-	preempt_enable();
+	rcu_read_unlock();
 #endif
 	/* if there are no users, entry can be NULL */
 	if (entry)
-- 
2.4.6

--
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