Skip to contentSkip to conversation

tracing: Fix to avoid creating trace instances with duplicate names

PATCH New Masami Hiramatsu (Google) 1 participant 1 message Sep 3 Tracing

lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

PATCH 1/1 tracing: Fix to avoid creating trace instances with duplicate names

From: Masami Hiramatsu (Google) <[email protected]>

Since commit e645535a954a ("tracing: Add option to use memmapped memory for trace boot instance") changed trace_array_get_by_name() to trace_array_create_systems(), enable_instances() does not reuse the same name instance. Therefore, if an administrator mistakenly specifies multiple trace_instance= options with duplicate names, all are created but only the first is accessible via tracefs.

Check whether an instance with the same name already exists before creating a new one, and reject duplicates with a warning.

Fixes e645535a954a ("tracing: Add option to use memmapped memory for trace boot instance")
---
 kernel/trace/trace.c |    5 +++++
 1 file changed, 5 insertions(+)
kernel/trace/trace.c +5 -0
index a946e0183fd1..536e71f28d51 100644
@@ -9651,6 +9651,11 @@ __init static void enable_instances(void)
 		if (flag_delim)
 			*flag_delim++ = '\0';
 
+		if (trace_array_find(name)) {
+			pr_warn("Tracing: Instance %s already exists\n", name);
+			continue;
+		}
+
 		if (backup) {
 			if (backup_instance_area(backup, &addr, &size) < 0)
 				continue;