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:	Thu, 30 Apr 2009 02:27:17 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Li Zefan <lizf@...fujitsu.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Zhao Lei <zhaolei@...fujitsu.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Tom Zanussi <tzanussi@...il.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 16/19] tracing/workqueue: add open/release file handlers

A stat tracer might want to free one of its entries in an atomic
context, this is the case for the workqueue tracer.

The problem is that the stat tracing framework can store a pointer
to a freed entry and pass it to the stat_next() and stat_show()
handlers.

Since this is the only tracer which suffers such issue for now, it's
better to implement the protection on the workqueue tracer layer
using a reader refcount.

These open/release callbacks are then added to help implementing
such facility.

[ Impact: prepare workqueue tracer to protect its entries freeing ]

Signed-off-by: Frederic Weisbecker <fweisbec@...il.com>
Cc: Zhao Lei <zhaolei@...fujitsu.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Tom Zanussi <tzanussi@...il.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
---
 kernel/trace/trace_stat.c |    8 ++++++++
 kernel/trace/trace_stat.h |    3 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index fdde3a4..04f3285 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -210,8 +210,13 @@ static int tracing_stat_open(struct inode *inode, struct file *file)
 	ret = seq_open(file, &trace_stat_seq_ops);
 	if (!ret) {
 		struct seq_file *m = file->private_data;
+
 		m->private = session;
+		if (session->ts->file_open)
+			session->ts->file_open();
 		ret = stat_seq_init(session);
+		if (ret && session->ts->file_release)
+			session->ts->file_release();
 	}
 
 	return ret;
@@ -228,6 +233,9 @@ static int tracing_stat_release(struct inode *i, struct file *f)
 	reset_stat_session(session);
 	mutex_unlock(&session->stat_mutex);
 
+	if (session->ts->file_release)
+		session->ts->file_release();
+
 	return 0;
 }
 
diff --git a/kernel/trace/trace_stat.h b/kernel/trace/trace_stat.h
index f3546a2..915bf2e 100644
--- a/kernel/trace/trace_stat.h
+++ b/kernel/trace/trace_stat.h
@@ -20,6 +20,9 @@ struct tracer_stat {
 	int			(*stat_show)(struct seq_file *s, void *p);
 	/* Print the headers of your stat entries */
 	int			(*stat_headers)(struct seq_file *s);
+	/* Hooks on file operations */
+	void			(*file_open)(void);
+	void			(*file_release)(void);
 };
 
 /*
-- 
1.6.2.3

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