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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 19 Jul 2013 17:51:01 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Ingo Molnar <mingo@...hat.com>,
	Steven Rostedt <rostedt@...dmis.org>
Cc:	Frederic Weisbecker <fweisbec@...il.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] tracing: Simplify trace_array_get()

trace_array_get() scans the global ftrace_trace_arrays list
to ensure that "this_tr" was not removed by instance_delete().

This looks a bit confusing, we can simply use list_empty() with
the same result. list_empty() == F can not be false positive,
new_instance_create() does everything under the same lock and
tracer_alloc_buffers() which plays with global_trace is __init.

Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
 kernel/trace/trace.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0cd500b..ee471fb 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -206,16 +206,12 @@ LIST_HEAD(ftrace_trace_arrays);
 
 int trace_array_get(struct trace_array *this_tr)
 {
-	struct trace_array *tr;
 	int ret = -ENODEV;
 
 	mutex_lock(&trace_types_lock);
-	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
-		if (tr == this_tr) {
-			tr->ref++;
-			ret = 0;
-			break;
-		}
+	if (!list_empty(&this_tr->list)) {
+		this_tr->ref++;
+		ret = 0;
 	}
 	mutex_unlock(&trace_types_lock);
 
@@ -6019,7 +6015,7 @@ static int instance_delete(const char *name)
 	if (tr->ref)
 		goto out_unlock;
 
-	list_del(&tr->list);
+	list_del_init(&tr->list); /* trace_array_get() checks list_empty() */
 
 	event_trace_del_tracer(tr);
 	debugfs_remove_recursive(tr->dir);
-- 
1.5.5.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