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:	Sat, 30 Jan 2016 18:23:36 +0800
From:	Weilong Chen <chenweilong@...wei.com>
To:	<linux-kernel@...r.kernel.org>, <jcm@...masters.org>,
	<rusty@...tcorp.com.au>
Subject: [PATCH] Race between cat /proc/kallsyms and rmmod

Iterating code of /proc/kallsyms calls module_get_kallsym() which grabs
and drops module_mutex internally and returns "struct module *",
module is removed, aforementioned "struct module *" is used in non-trivial
way.

So, grab module_mutex for entire operation like /proc/modules does.

Steps to reproduce:
while true; do modprobe xfs; rmmod xfs; done
vs
while true; do cat /proc/kallsyms >/dev/null; done

ref:http://lkml.iu.edu/hypermail/linux/kernel/0703.1/2582.html
    https://bugzilla.kernel.org/show_bug.cgi?id=111541

Signed-off-by: Weilong Chen <chenweilong@...wei.com>
---
 kernel/kallsyms.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 3127ad5..aaecf19 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -515,6 +515,7 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos)
 
 static void *s_start(struct seq_file *m, loff_t *pos)
 {
+	mutex_lock(&module_mutex);
 	if (!update_iter(m->private, *pos))
 		return NULL;
 	return m->private;
@@ -522,6 +523,7 @@ static void *s_start(struct seq_file *m, loff_t *pos)
 
 static void s_stop(struct seq_file *m, void *p)
 {
+	mutex_unlock(&module_mutex);
 }
 
 static int s_show(struct seq_file *m, void *p)
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ