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]
Message-Id: <1311742583-18633-1-git-send-email-yong.zhang0@gmail.com>
Date:	Wed, 27 Jul 2011 12:56:22 +0800
From:	Yong Zhang <yong.zhang0@...il.com>
To:	linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Keika Kobayashi <kobayashi.kk@...s.nec.co.jp>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Heiko Carstens <heiko.carstens@...ibm.com>
Subject: [PATCH 1/2] proc/insterrupts: make it cpu hotplug safe

KOSAKI Motonhiro noticed that the reader of /proc/interrupts
could be preempted by cpu hotplug, thus the reader can get
broken result due to show_interrupts() iterate every online
cpu without any protection.

Signed-off-by: Yong Zhang <yong.zhang0@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Keika Kobayashi <kobayashi.kk@...s.nec.co.jp>
Cc: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Cc: Heiko Carstens <heiko.carstens@...ibm.com>
---
 fs/proc/interrupts.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index 05029c0..d5642a6 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -4,6 +4,7 @@
 #include <linux/irqnr.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/cpu.h>
 
 /*
  * /proc/interrupts
@@ -35,14 +36,21 @@ static const struct seq_operations int_seq_ops = {
 
 static int interrupts_open(struct inode *inode, struct file *filp)
 {
+	get_online_cpus();
 	return seq_open(filp, &int_seq_ops);
 }
 
+static int interrupts_release(struct inode *inode, struct file *filp)
+{
+	put_online_cpus();
+	return seq_release(inode, filp);
+}
+
 static const struct file_operations proc_interrupts_operations = {
 	.open		= interrupts_open,
 	.read		= seq_read,
 	.llseek		= seq_lseek,
-	.release	= seq_release,
+	.release	= interrupts_release,
 };
 
 static int __init proc_interrupts_init(void)
-- 
1.7.4.1

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