public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
@ 2013-07-30 11:27 Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 1/8] tracing: Turn event/id->i_private into call->event.type Steven Rostedt
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

Oleg has been continuing his work on fixing a race between opening an
event file and deleting that same event. Using the i_private and event_mutex
to verify that the event still exists to solve the race.

A long standing bug on the ftrace hash accounting has finally been figured
out. When tracing a module that is removed and then reloaded, the function
filter hash gets out of sync with the function record's ref count which
causes a nasty warning and disabling of the function tracer.

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 6fd52fce057b55cc1bba463e6f05536a76c058b4


Oleg Nesterov (6):
      tracing: Turn event/id->i_private into call->event.type
      tracing: Change event_enable/disable_read() to verify i_private != NULL
      tracing: Change event_filter_read/write to verify i_private != NULL
      tracing: Change f_start() to take event_mutex and verify i_private != NULL
      tracing: Introduce remove_event_file_dir()
      tracing: Change remove_event_file_dir() to clear "d_subdirs"->i_private

Steven Rostedt (Red Hat) (2):
      ftrace: Consolidate some duplicate code for updating ftrace ops
      ftrace: Clear module traced functions on unload module

----
 kernel/trace/ftrace.c              |   76 +++++++++++++++--
 kernel/trace/trace_events.c        |  159 ++++++++++++++++++++----------------
 kernel/trace/trace_events_filter.c |   17 ++--
 3 files changed, 164 insertions(+), 88 deletions(-)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 1/8] tracing: Turn event/id->i_private into call->event.type
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 2/8] tracing: Change event_enable/disable_read() to verify i_private != NULL Steven Rostedt
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0001-tracing-Turn-event-id-i_private-into-call-event.type.patch --]
[-- Type: text/plain, Size: 2444 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

event_id_read() is racy, ftrace_event_call can be already freed
by trace_remove_event_call() callers.

Change event_create_dir() to pass "data = call->event.type", this
is all event_id_read() needs. ftrace_event_id_fops no longer needs
tracing_open_generic().

We add the new helper, event_file_data(), to read ->i_private, it
will have more users.

Note: currently ACCESS_ONCE() and "id != 0" check are not needed,
but we are going to change event_remove/rmdir to clear ->i_private.

Link: http://lkml.kernel.org/r/20130726172532.GA3605@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 898f868..c2d13c5 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -409,6 +409,11 @@ static void put_system(struct ftrace_subsystem_dir *dir)
 	mutex_unlock(&event_mutex);
 }
 
+static void *event_file_data(struct file *filp)
+{
+	return ACCESS_ONCE(file_inode(filp)->i_private);
+}
+
 /*
  * Open and update trace_array ref count.
  * Must have the current trace_array passed to it.
@@ -946,14 +951,18 @@ static int trace_format_open(struct inode *inode, struct file *file)
 static ssize_t
 event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
 {
-	struct ftrace_event_call *call = filp->private_data;
+	int id = (long)event_file_data(filp);
 	char buf[32];
 	int len;
 
 	if (*ppos)
 		return 0;
 
-	len = sprintf(buf, "%d\n", call->event.type);
+	if (unlikely(!id))
+		return -ENODEV;
+
+	len = sprintf(buf, "%d\n", id);
+
 	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
 }
 
@@ -1240,7 +1249,6 @@ static const struct file_operations ftrace_event_format_fops = {
 };
 
 static const struct file_operations ftrace_event_id_fops = {
-	.open = tracing_open_generic,
 	.read = event_id_read,
 	.llseek = default_llseek,
 };
@@ -1488,8 +1496,8 @@ event_create_dir(struct dentry *parent,
 
 #ifdef CONFIG_PERF_EVENTS
 	if (call->event.type && call->class->reg)
-		trace_create_file("id", 0444, file->dir, call,
-		 		  id);
+		trace_create_file("id", 0444, file->dir,
+				  (void *)(long)call->event.type, id);
 #endif
 
 	/*
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 2/8] tracing: Change event_enable/disable_read() to verify i_private != NULL
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 1/8] tracing: Turn event/id->i_private into call->event.type Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 3/8] tracing: Change event_filter_read/write " Steven Rostedt
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0002-tracing-Change-event_enable-disable_read-to-verify-i.patch --]
[-- Type: text/plain, Size: 2546 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

tracing_open_generic_file() is racy, ftrace_event_file can be
already freed by rmdir or trace_remove_event_call().

Change event_enable_read() and event_disable_read() to read and
verify "file = i_private" under event_mutex.

This fixes nothing, but now we can change debugfs_remove("enable")
callers to nullify ->i_private and fix the the problem.

Link: http://lkml.kernel.org/r/20130726172536.GA3612@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |   30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index c2d13c5..3dfa841 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -684,15 +684,25 @@ static ssize_t
 event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
 		  loff_t *ppos)
 {
-	struct ftrace_event_file *file = filp->private_data;
+	struct ftrace_event_file *file;
+	unsigned long flags;
 	char buf[4] = "0";
 
-	if (file->flags & FTRACE_EVENT_FL_ENABLED &&
-	    !(file->flags & FTRACE_EVENT_FL_SOFT_DISABLED))
+	mutex_lock(&event_mutex);
+	file = event_file_data(filp);
+	if (likely(file))
+		flags = file->flags;
+	mutex_unlock(&event_mutex);
+
+	if (!file)
+		return -ENODEV;
+
+	if (flags & FTRACE_EVENT_FL_ENABLED &&
+	    !(flags & FTRACE_EVENT_FL_SOFT_DISABLED))
 		strcpy(buf, "1");
 
-	if (file->flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
-	    file->flags & FTRACE_EVENT_FL_SOFT_MODE)
+	if (flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
+	    flags & FTRACE_EVENT_FL_SOFT_MODE)
 		strcat(buf, "*");
 
 	strcat(buf, "\n");
@@ -704,13 +714,10 @@ static ssize_t
 event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 		   loff_t *ppos)
 {
-	struct ftrace_event_file *file = filp->private_data;
+	struct ftrace_event_file *file;
 	unsigned long val;
 	int ret;
 
-	if (!file)
-		return -EINVAL;
-
 	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
 	if (ret)
 		return ret;
@@ -722,8 +729,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	switch (val) {
 	case 0:
 	case 1:
+		ret = -ENODEV;
 		mutex_lock(&event_mutex);
-		ret = ftrace_event_enable_disable(file, val);
+		file = event_file_data(filp);
+		if (likely(file))
+			ret = ftrace_event_enable_disable(file, val);
 		mutex_unlock(&event_mutex);
 		break;
 
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 3/8] tracing: Change event_filter_read/write to verify i_private != NULL
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 1/8] tracing: Turn event/id->i_private into call->event.type Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 2/8] tracing: Change event_enable/disable_read() to verify i_private != NULL Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 4/8] tracing: Change f_start() to take event_mutex and " Steven Rostedt
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0003-tracing-Change-event_filter_read-write-to-verify-i_p.patch --]
[-- Type: text/plain, Size: 4194 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

event_filter_read/write() are racy, ftrace_event_call can be already
freed by trace_remove_event_call() callers.

1. Shift mutex_lock(event_mutex) from print/apply_event_filter to
   the callers.

2. Change the callers, event_filter_read() and event_filter_write()
   to read i_private under this mutex and abort if it is NULL.

This fixes nothing, but now we can change debugfs_remove("filter")
callers to nullify ->i_private and fix the the problem.

Link: http://lkml.kernel.org/r/20130726172540.GA3619@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c        |   26 +++++++++++++++++++-------
 kernel/trace/trace_events_filter.c |   17 ++++++-----------
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 3dfa841..1d7b6d0 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -980,21 +980,28 @@ static ssize_t
 event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
 		  loff_t *ppos)
 {
-	struct ftrace_event_call *call = filp->private_data;
+	struct ftrace_event_call *call;
 	struct trace_seq *s;
-	int r;
+	int r = -ENODEV;
 
 	if (*ppos)
 		return 0;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
+
 	if (!s)
 		return -ENOMEM;
 
 	trace_seq_init(s);
 
-	print_event_filter(call, s);
-	r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
+	mutex_lock(&event_mutex);
+	call = event_file_data(filp);
+	if (call)
+		print_event_filter(call, s);
+	mutex_unlock(&event_mutex);
+
+	if (call)
+		r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
 
 	kfree(s);
 
@@ -1005,9 +1012,9 @@ static ssize_t
 event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 		   loff_t *ppos)
 {
-	struct ftrace_event_call *call = filp->private_data;
+	struct ftrace_event_call *call;
 	char *buf;
-	int err;
+	int err = -ENODEV;
 
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
@@ -1022,7 +1029,12 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	}
 	buf[cnt] = '\0';
 
-	err = apply_event_filter(call, buf);
+	mutex_lock(&event_mutex);
+	call = event_file_data(filp);
+	if (call)
+		err = apply_event_filter(call, buf);
+	mutex_unlock(&event_mutex);
+
 	free_page((unsigned long) buf);
 	if (err < 0)
 		return err;
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 0c7b75a..97daa8c 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -637,17 +637,15 @@ static void append_filter_err(struct filter_parse_state *ps,
 	free_page((unsigned long) buf);
 }
 
+/* caller must hold event_mutex */
 void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
 {
-	struct event_filter *filter;
+	struct event_filter *filter = call->filter;
 
-	mutex_lock(&event_mutex);
-	filter = call->filter;
 	if (filter && filter->filter_string)
 		trace_seq_printf(s, "%s\n", filter->filter_string);
 	else
 		trace_seq_puts(s, "none\n");
-	mutex_unlock(&event_mutex);
 }
 
 void print_subsystem_event_filter(struct event_subsystem *system,
@@ -1841,23 +1839,22 @@ static int create_system_filter(struct event_subsystem *system,
 	return err;
 }
 
+/* caller must hold event_mutex */
 int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
 {
 	struct event_filter *filter;
-	int err = 0;
-
-	mutex_lock(&event_mutex);
+	int err;
 
 	if (!strcmp(strstrip(filter_string), "0")) {
 		filter_disable(call);
 		filter = call->filter;
 		if (!filter)
-			goto out_unlock;
+			return 0;
 		RCU_INIT_POINTER(call->filter, NULL);
 		/* Make sure the filter is not being used */
 		synchronize_sched();
 		__free_filter(filter);
-		goto out_unlock;
+		return 0;
 	}
 
 	err = create_filter(call, filter_string, true, &filter);
@@ -1884,8 +1881,6 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
 			__free_filter(tmp);
 		}
 	}
-out_unlock:
-	mutex_unlock(&event_mutex);
 
 	return err;
 }
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 4/8] tracing: Change f_start() to take event_mutex and verify i_private != NULL
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (2 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 3/8] tracing: Change event_filter_read/write " Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 5/8] tracing: Introduce remove_event_file_dir() Steven Rostedt
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0004-tracing-Change-f_start-to-take-event_mutex-and-verif.patch --]
[-- Type: text/plain, Size: 2632 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

trace_format_open() and trace_format_seq_ops are racy, nothing
protects ftrace_event_call from trace_remove_event_call().

Change f_start() to take event_mutex and verify i_private != NULL,
change f_stop() to drop this lock.

This fixes nothing, but now we can change debugfs_remove("format")
callers to nullify ->i_private and fix the the problem.

Note: the usage of event_mutex is sub-optimal but simple, we can
change this later.

Link: http://lkml.kernel.org/r/20130726172543.GA3622@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 1d7b6d0..50dc8b2 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -840,7 +840,7 @@ enum {
 
 static void *f_next(struct seq_file *m, void *v, loff_t *pos)
 {
-	struct ftrace_event_call *call = m->private;
+	struct ftrace_event_call *call = event_file_data(m->private);
 	struct list_head *common_head = &ftrace_common_fields;
 	struct list_head *head = trace_get_fields(call);
 	struct list_head *node = v;
@@ -872,7 +872,7 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
 
 static int f_show(struct seq_file *m, void *v)
 {
-	struct ftrace_event_call *call = m->private;
+	struct ftrace_event_call *call = event_file_data(m->private);
 	struct ftrace_event_field *field;
 	const char *array_descriptor;
 
@@ -925,6 +925,11 @@ static void *f_start(struct seq_file *m, loff_t *pos)
 	void *p = (void *)FORMAT_HEADER;
 	loff_t l = 0;
 
+	/* ->stop() is called even if ->start() fails */
+	mutex_lock(&event_mutex);
+	if (!event_file_data(m->private))
+		return ERR_PTR(-ENODEV);
+
 	while (l < *pos && p)
 		p = f_next(m, p, &l);
 
@@ -933,6 +938,7 @@ static void *f_start(struct seq_file *m, loff_t *pos)
 
 static void f_stop(struct seq_file *m, void *p)
 {
+	mutex_unlock(&event_mutex);
 }
 
 static const struct seq_operations trace_format_seq_ops = {
@@ -944,7 +950,6 @@ static const struct seq_operations trace_format_seq_ops = {
 
 static int trace_format_open(struct inode *inode, struct file *file)
 {
-	struct ftrace_event_call *call = inode->i_private;
 	struct seq_file *m;
 	int ret;
 
@@ -953,7 +958,7 @@ static int trace_format_open(struct inode *inode, struct file *file)
 		return ret;
 
 	m = file->private_data;
-	m->private = call;
+	m->private = file;
 
 	return 0;
 }
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 5/8] tracing: Introduce remove_event_file_dir()
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (3 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 4/8] tracing: Change f_start() to take event_mutex and " Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 6/8] tracing: Change remove_event_file_dir() to clear "d_subdirs"->i_private Steven Rostedt
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0005-tracing-Introduce-remove_event_file_dir.patch --]
[-- Type: text/plain, Size: 2869 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

Preparation for the next patch. Extract the common code from
remove_event_from_tracers() and __trace_remove_event_dirs()
into the new helper, remove_event_file_dir().

The patch looks more complicated than it actually is, it also
moves remove_subsystem() up to avoid the forward declaration.

Link: http://lkml.kernel.org/r/20130726172547.GA3629@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |   47 +++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 50dc8b2..05d647e 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -409,11 +409,31 @@ static void put_system(struct ftrace_subsystem_dir *dir)
 	mutex_unlock(&event_mutex);
 }
 
+static void remove_subsystem(struct ftrace_subsystem_dir *dir)
+{
+	if (!dir)
+		return;
+
+	if (!--dir->nr_events) {
+		debugfs_remove_recursive(dir->entry);
+		list_del(&dir->list);
+		__put_system_dir(dir);
+	}
+}
+
 static void *event_file_data(struct file *filp)
 {
 	return ACCESS_ONCE(file_inode(filp)->i_private);
 }
 
+static void remove_event_file_dir(struct ftrace_event_file *file)
+{
+	list_del(&file->list);
+	debugfs_remove_recursive(file->dir);
+	remove_subsystem(file->system);
+	kmem_cache_free(file_cachep, file);
+}
+
 /*
  * Open and update trace_array ref count.
  * Must have the current trace_array passed to it.
@@ -1549,33 +1569,16 @@ event_create_dir(struct dentry *parent,
 	return 0;
 }
 
-static void remove_subsystem(struct ftrace_subsystem_dir *dir)
-{
-	if (!dir)
-		return;
-
-	if (!--dir->nr_events) {
-		debugfs_remove_recursive(dir->entry);
-		list_del(&dir->list);
-		__put_system_dir(dir);
-	}
-}
-
 static void remove_event_from_tracers(struct ftrace_event_call *call)
 {
 	struct ftrace_event_file *file;
 	struct trace_array *tr;
 
 	do_for_each_event_file_safe(tr, file) {
-
 		if (file->event_call != call)
 			continue;
 
-		list_del(&file->list);
-		debugfs_remove_recursive(file->dir);
-		remove_subsystem(file->system);
-		kmem_cache_free(file_cachep, file);
-
+		remove_event_file_dir(file);
 		/*
 		 * The do_for_each_event_file_safe() is
 		 * a double loop. After finding the call for this
@@ -2305,12 +2308,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
 {
 	struct ftrace_event_file *file, *next;
 
-	list_for_each_entry_safe(file, next, &tr->events, list) {
-		list_del(&file->list);
-		debugfs_remove_recursive(file->dir);
-		remove_subsystem(file->system);
-		kmem_cache_free(file_cachep, file);
-	}
+	list_for_each_entry_safe(file, next, &tr->events, list)
+		remove_event_file_dir(file);
 }
 
 static void
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 6/8] tracing: Change remove_event_file_dir() to clear "d_subdirs"->i_private
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (4 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 5/8] tracing: Introduce remove_event_file_dir() Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 7/8] ftrace: Consolidate some duplicate code for updating ftrace ops Steven Rostedt
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0006-tracing-Change-remove_event_file_dir-to-clear-d_subd.patch --]
[-- Type: text/plain, Size: 3281 bytes --]

From: Oleg Nesterov <oleg@redhat.com>

Change remove_event_file_dir() to clear ->i_private for every
file we are going to remove.

We need to check file->dir != NULL because event_create_dir()
can fail. debugfs_remove_recursive(NULL) is fine but the patch
moves it under the same check anyway for readability.

spin_lock(d_lock) and "d_inode != NULL" check are not needed
afaics, but I do not understand this code enough.

tracing_open_generic_file() and tracing_release_generic_file()
can go away, ftrace_enable_fops and ftrace_event_filter_fops()
use tracing_open_generic() but only to check tracing_disabled.

This fixes all races with event_remove() or instance_delete().
f_op->read/write/whatever can never use the freed file/call,
all event/* files were changed to check and use ->i_private
under event_mutex.

Note: this doesn't not fix other problems, event_remove() can
destroy the active ftrace_event_call, we need more changes but
those changes are completely orthogonal.

Link: http://lkml.kernel.org/r/20130728183527.GB16723@redhat.com

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |   47 ++++++++++++++-----------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 05d647e..a67c913 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -428,42 +428,26 @@ static void *event_file_data(struct file *filp)
 
 static void remove_event_file_dir(struct ftrace_event_file *file)
 {
+	struct dentry *dir = file->dir;
+	struct dentry *child;
+
+	if (dir) {
+		spin_lock(&dir->d_lock);	/* probably unneeded */
+		list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) {
+			if (child->d_inode)	/* probably unneeded */
+				child->d_inode->i_private = NULL;
+		}
+		spin_unlock(&dir->d_lock);
+
+		debugfs_remove_recursive(dir);
+	}
+
 	list_del(&file->list);
-	debugfs_remove_recursive(file->dir);
 	remove_subsystem(file->system);
 	kmem_cache_free(file_cachep, file);
 }
 
 /*
- * Open and update trace_array ref count.
- * Must have the current trace_array passed to it.
- */
-static int tracing_open_generic_file(struct inode *inode, struct file *filp)
-{
-	struct ftrace_event_file *file = inode->i_private;
-	struct trace_array *tr = file->tr;
-	int ret;
-
-	if (trace_array_get(tr) < 0)
-		return -ENODEV;
-
-	ret = tracing_open_generic(inode, filp);
-	if (ret < 0)
-		trace_array_put(tr);
-	return ret;
-}
-
-static int tracing_release_generic_file(struct inode *inode, struct file *filp)
-{
-	struct ftrace_event_file *file = inode->i_private;
-	struct trace_array *tr = file->tr;
-
-	trace_array_put(tr);
-
-	return 0;
-}
-
-/*
  * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
  */
 static int
@@ -1281,10 +1265,9 @@ static const struct file_operations ftrace_set_event_fops = {
 };
 
 static const struct file_operations ftrace_enable_fops = {
-	.open = tracing_open_generic_file,
+	.open = tracing_open_generic,
 	.read = event_enable_read,
 	.write = event_enable_write,
-	.release = tracing_release_generic_file,
 	.llseek = default_llseek,
 };
 
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 7/8] ftrace: Consolidate some duplicate code for updating ftrace ops
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (5 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 6/8] tracing: Change remove_event_file_dir() to clear "d_subdirs"->i_private Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 11:27 ` [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module Steven Rostedt
  2013-07-31 11:47 ` [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Oleg Nesterov
  8 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov

[-- Attachment #1: 0007-ftrace-Consolidate-some-duplicate-code-for-updating-.patch --]
[-- Type: text/plain, Size: 1869 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

When ftrace ops modifies the functions that it will trace, the update
to the function mcount callers may need to be modified. Consolidate
the two places that do the checks to see if an update is required
with a wrapper function for those checks.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8ce9eef..92d3334 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3384,6 +3384,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
 	return add_hash_entry(hash, ip);
 }
 
+static void ftrace_ops_update_code(struct ftrace_ops *ops)
+{
+	if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
+		ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+}
+
 static int
 ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 		unsigned long ip, int remove, int reset, int enable)
@@ -3426,9 +3432,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 
 	mutex_lock(&ftrace_lock);
 	ret = ftrace_hash_move(ops, enable, orig_hash, hash);
-	if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED
-	    && ftrace_enabled)
-		ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+	if (!ret)
+		ftrace_ops_update_code(ops);
 
 	mutex_unlock(&ftrace_lock);
 
@@ -3655,9 +3660,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
 		mutex_lock(&ftrace_lock);
 		ret = ftrace_hash_move(iter->ops, filter_hash,
 				       orig_hash, iter->hash);
-		if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED)
-		    && ftrace_enabled)
-			ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+		if (!ret)
+			ftrace_ops_update_code(iter->ops);
 
 		mutex_unlock(&ftrace_lock);
 	}
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (6 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 7/8] ftrace: Consolidate some duplicate code for updating ftrace ops Steven Rostedt
@ 2013-07-30 11:27 ` Steven Rostedt
  2013-07-30 17:39   ` Steven Rostedt
  2013-07-31 11:47 ` [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Oleg Nesterov
  8 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 11:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov, Jörn Engel, Dave Jones, Steve Hodgson

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0008-ftrace-Clear-module-traced-functions-on-unload-modul.patch --]
[-- Type: text/plain, Size: 5844 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

There's been a nasty bug that would show up and not give much info.
The bug displayed the following warning:

 WARNING: at kernel/trace/ftrace.c:1529 __ftrace_hash_rec_update+0x1e3/0x230()
 Pid: 20903, comm: bash Tainted: G           O 3.6.11+ #38405.trunk
 Call Trace:
  [<ffffffff8103e5ff>] warn_slowpath_common+0x7f/0xc0
  [<ffffffff8103e65a>] warn_slowpath_null+0x1a/0x20
  [<ffffffff810c2ee3>] __ftrace_hash_rec_update+0x1e3/0x230
  [<ffffffff810c4f28>] ftrace_hash_move+0x28/0x1d0
  [<ffffffff811401cc>] ? kfree+0x2c/0x110
  [<ffffffff810c68ee>] ftrace_regex_release+0x8e/0x150
  [<ffffffff81149f1e>] __fput+0xae/0x220
  [<ffffffff8114a09e>] ____fput+0xe/0x10
  [<ffffffff8105fa22>] task_work_run+0x72/0x90
  [<ffffffff810028ec>] do_notify_resume+0x6c/0xc0
  [<ffffffff8126596e>] ? trace_hardirqs_on_thunk+0x3a/0x3c
  [<ffffffff815c0f88>] int_signal+0x12/0x17
 ---[ end trace 793179526ee09b2c ]---

It was finally narrowed down to unloading a module that was being traced.

It was actually more than that. When functions are being traced, there's
a table of all functions that have a ref count of the number of active
tracers attached to that function. When a function trace callback is
registered to a function, the function's record ref count is incremented.
When it is unregistered, the function's record ref count is decremented.
If an inconsistency is detected (ref count goes below zero) the above
warning is shown and the function tracing is permanently disabled until
reboot.

When a module is unloaded, it frees the function records that represent
the module functions. These records exist on their own pages, that is
function records for one module will not exist on the same page as
function records for other modules or even the core kernel.

Now, when a callback is registered to a function, it holds a "hash" of
function addresses that it traces. When it unregisters, the hash is
examined and any record that exists in the hash will decrement the
functions record's ref count. Hashes that point to a module function
that was freed are simply ignored.

But what happens if the trace is still going on and you reload the same
module. If the module is allocated in the same location, the hashes
of the registered functions will still be mapped to the module functions
(if it was tracing the module function). The problem is that the module
would allocate new function record tables with their ref counts as zero.
When a callback is unregistered, if the hash matches the function record
of a reloaded module, it will dec the ref count, but as it was zero it
would trigger the above warning and disable function tracing.

With the help of Steve and Joern, we found a reproducer:

 Using uinput module and uinput_release function.

 modprobe uinput
 echo uinput_release > /sys/kernel/debug/tracing/set_ftrace_filter
 rmmod uinput
 modprobe uinput
 // check /proc/modules to see if loaded in same addr, otherwise try again
 echo > /sys/kernel/debug/tracing/set_ftrace_filter

 [BOOM]

The solution here is on module unload, look at all the registered funtion
callbacks and remove any hash entry that points to any function in the
module that is about to be removed.

Link: http://lkml.kernel.org/r/CADHUQJ58icP+d3QTXheiCnZwu6hrAqG2heMhhcuQvghXavHRFw@mail.gmail.com

Reported-by: Jörn Engel <joern@logfs.org>
Reported-by: Dave Jones <davej@redhat.com>
Reported-by: Steve Hodgson <steve@purestorage.com>
Tested-by: Steve Hodgson <steve@purestorage.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 92d3334..6de8cbd 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4061,6 +4061,63 @@ static int ftrace_process_locs(struct module *mod,
 
 #ifdef CONFIG_MODULES
 
+/*
+ * If the filter is cleared, then all functions may end up being
+ * traced. We need to pass that information down to update the
+ * records.
+ */
+static bool remove_rec_entry(struct ftrace_hash *hash, struct dyn_ftrace *rec)
+{
+	struct ftrace_func_entry *entry;
+
+	entry = ftrace_lookup_ip(hash, rec->ip);
+	if (!entry)
+		return false;
+
+	free_hash_entry(hash, entry);
+
+	/* If we cleared the hash, then we now trace all functions */
+	return ftrace_hash_empty(hash);
+}
+
+static void clear_recs(struct ftrace_ops *ops, struct ftrace_page *pg)
+{
+	struct dyn_ftrace *rec;
+	bool update = false;
+	int i;
+
+	for (i = 0; i < pg->index; i++) {
+		rec = &pg->records[i];
+
+		/* If the filter hash gets cleared, we trace all functions */
+		if (remove_rec_entry(ops->filter_hash, rec))
+			update = true;
+		remove_rec_entry(ops->notrace_hash, rec);
+	}
+
+	if (update) {
+		ftrace_hash_rec_enable(ops, 1);
+		if (ftrace_enabled)
+			ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+	}
+}
+
+static bool ops_has_filter(struct ftrace_ops *ops)
+{
+	return !ftrace_hash_empty(ops->filter_hash) ||
+		!ftrace_hash_empty(ops->notrace_hash);
+}
+
+static void clear_hashes(struct ftrace_page *pg)
+{
+	struct ftrace_ops *ops;
+
+	for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
+		if ((ops->flags & FTRACE_OPS_FL_ENABLED) && ops_has_filter(ops))
+			clear_recs(ops, pg);
+	}
+}
+
 #define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next)
 
 void ftrace_release_mod(struct module *mod)
@@ -4094,6 +4151,9 @@ void ftrace_release_mod(struct module *mod)
 			if (pg == ftrace_pages)
 				ftrace_pages = next_to_ftrace_page(last_pg);
 
+			/* Make sure no hashes reference this module record */
+			clear_hashes(pg);
+
 			*last_pg = pg->next;
 			order = get_count_order(pg->size / ENTRIES_PER_PAGE);
 			free_pages((unsigned long)pg->records, order);
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module
  2013-07-30 11:27 ` [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module Steven Rostedt
@ 2013-07-30 17:39   ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-30 17:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Frederic Weisbecker, Andrew Morton, Masami Hiramatsu,
	Oleg Nesterov, Jörn Engel, Dave Jones, Steve Hodgson

On Tue, 2013-07-30 at 07:27 -0400, Steven Rostedt wrote:

> The solution here is on module unload, look at all the registered funtion
> callbacks and remove any hash entry that points to any function in the
> module that is about to be removed.

There's another bug that is very similar to this one. I originally did a
ref count to ops, but I didn't really like it (it was included in what
Steve tested). While looking at other solutions I think I have something
that may be a bit better. It wont clear the trace on module reload, but
it can reenable the trace if a module is loaded with a function at the
same address that was traced before.

Sure this may be a bit confusing if another module gets traced, but it
allows for tracing functions on module load, which is useful.

I'm working on a new patch and hopefully Steve can test that one too.

Thanks,

-- Steve



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
  2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
                   ` (7 preceding siblings ...)
  2013-07-30 11:27 ` [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module Steven Rostedt
@ 2013-07-31 11:47 ` Oleg Nesterov
  2013-07-31 14:06   ` Steven Rostedt
  8 siblings, 1 reply; 15+ messages in thread
From: Oleg Nesterov @ 2013-07-31 11:47 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Masami Hiramatsu

On 07/30, Steven Rostedt wrote:
>
> Using the i_private and event_mutex
> to verify that the event still exists to solve the race.

To remind, we also need the "debugfs: debugfs_remove_recursive() must
not rely on list_empty(d_subdirs)" patch, otherwise we still have the
problems with the opened files.

Just in case, we need this fix even if .open() does trace_array_get()
or tracing_open_generic_file() (removed by recent changes), rmdir can
be called before we increment the counter and the deleted dentry breaks
debugfs_remove_recursive().

But after the recent changes this fix becomes more important. An opened
file confuses debugfs_remove_recursive() and after that you can't create
another probe.

Oleg.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
  2013-07-31 11:47 ` [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Oleg Nesterov
@ 2013-07-31 14:06   ` Steven Rostedt
  2013-07-31 14:22     ` Oleg Nesterov
  0 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2013-07-31 14:06 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Masami Hiramatsu

On Wed, 2013-07-31 at 13:47 +0200, Oleg Nesterov wrote:
> On 07/30, Steven Rostedt wrote:
> >
> > Using the i_private and event_mutex
> > to verify that the event still exists to solve the race.
> 
> To remind, we also need the "debugfs: debugfs_remove_recursive() must
> not rely on list_empty(d_subdirs)" patch, otherwise we still have the
> problems with the opened files.

Do these patches depend on that patch? Should I rebase to have that
patch first?

-- Steve

> 
> Just in case, we need this fix even if .open() does trace_array_get()
> or tracing_open_generic_file() (removed by recent changes), rmdir can
> be called before we increment the counter and the deleted dentry breaks
> debugfs_remove_recursive().
> 
> But after the recent changes this fix becomes more important. An opened
> file confuses debugfs_remove_recursive() and after that you can't create
> another probe.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
  2013-07-31 14:06   ` Steven Rostedt
@ 2013-07-31 14:22     ` Oleg Nesterov
  2013-07-31 14:29       ` Oleg Nesterov
  2013-07-31 16:43       ` Steven Rostedt
  0 siblings, 2 replies; 15+ messages in thread
From: Oleg Nesterov @ 2013-07-31 14:22 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Masami Hiramatsu

On 07/31, Steven Rostedt wrote:
>
> On Wed, 2013-07-31 at 13:47 +0200, Oleg Nesterov wrote:
> > On 07/30, Steven Rostedt wrote:
> > >
> > > Using the i_private and event_mutex
> > > to verify that the event still exists to solve the race.
> >
> > To remind, we also need the "debugfs: debugfs_remove_recursive() must
> > not rely on list_empty(d_subdirs)" patch, otherwise we still have the
> > problems with the opened files.
>
> Do these patches depend on that patch?

No,

> Should I rebase to have that
> patch first?

And no.

That patch fixes the buggy debugfs_remove_recursive() and nothing else.

The test-case from the changelog can trigger the problem with or without
the recent changes. You can't (I hope) crash the kernel this way after
these changes, but the undeleted directory is still obviously bad.

Just I think that "open/delete fixes" is not complete without this fix.

Oleg.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
  2013-07-31 14:22     ` Oleg Nesterov
@ 2013-07-31 14:29       ` Oleg Nesterov
  2013-07-31 16:43       ` Steven Rostedt
  1 sibling, 0 replies; 15+ messages in thread
From: Oleg Nesterov @ 2013-07-31 14:29 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Masami Hiramatsu

Sorry for noise, forgot to mention...

On 07/31, Oleg Nesterov wrote:
>
> Just I think that "open/delete fixes" is not complete without this fix.

And without the last "tracing: trace_remove_event_call() should fail if
call/file is in use" or something similar.

Oleg.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes
  2013-07-31 14:22     ` Oleg Nesterov
  2013-07-31 14:29       ` Oleg Nesterov
@ 2013-07-31 16:43       ` Steven Rostedt
  1 sibling, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2013-07-31 16:43 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Andrew Morton,
	Masami Hiramatsu

On Wed, 2013-07-31 at 16:22 +0200, Oleg Nesterov wrote:

> That patch fixes the buggy debugfs_remove_recursive() and nothing else.

Cool, I just pulled it in, and added your test case as part of my test
suite.

> 
> The test-case from the changelog can trigger the problem with or without
> the recent changes. You can't (I hope) crash the kernel this way after
> these changes, but the undeleted directory is still obviously bad.
> 
> Just I think that "open/delete fixes" is not complete without this fix.

OK, I'll start running it through my tests and I'll be pushing it out
later today. I'm still waiting on a "tested-by" for one of my other
patches.

Thanks!

-- Steve



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-31 16:43 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-30 11:27 [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 1/8] tracing: Turn event/id->i_private into call->event.type Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 2/8] tracing: Change event_enable/disable_read() to verify i_private != NULL Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 3/8] tracing: Change event_filter_read/write " Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 4/8] tracing: Change f_start() to take event_mutex and " Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 5/8] tracing: Introduce remove_event_file_dir() Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 6/8] tracing: Change remove_event_file_dir() to clear "d_subdirs"->i_private Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 7/8] ftrace: Consolidate some duplicate code for updating ftrace ops Steven Rostedt
2013-07-30 11:27 ` [for-next-3.11][PATCH 8/8] ftrace: Clear module traced functions on unload module Steven Rostedt
2013-07-30 17:39   ` Steven Rostedt
2013-07-31 11:47 ` [for-next-3.11][PATCH 0/8] ftrace/tracing: Event file fixes and ftrace function hash fixes Oleg Nesterov
2013-07-31 14:06   ` Steven Rostedt
2013-07-31 14:22     ` Oleg Nesterov
2013-07-31 14:29       ` Oleg Nesterov
2013-07-31 16:43       ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox