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: <20210812005546.910833-2-rostedt@goodmis.org>
Date:   Wed, 11 Aug 2021 20:55:45 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     linux-trace-devel@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, Tom Zanussi <zanussi@...nel.org>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        "Steven Rostedt (VMware)" <rostedt@...dmis.org>
Subject: [PATCH 1/2] libtracefs: Add random number to keep synthetic variables unique

From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>

The 'hist' triggers expect that all variables are unique. If two synthetic
events are created, it is possible that they will use the same variable
names, and this can break the logic for synthetic events. Add a random
number to the argument names that will help prevent that from happening.
There's no guarantee that there wont be collisions, but the chances of
that happening is 1 in 65535. If this is a problem, we could possibly look
for variables that are already in use.

Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
 src/tracefs-hist.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index 7f9cf3820611..8783ef4364bd 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -13,6 +13,8 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <time.h>
+#include <sys/types.h>
 
 #include "tracefs.h"
 #include "tracefs-local.h"
@@ -558,6 +560,7 @@ struct tracefs_synth {
 	unsigned int		end_parens;
 	unsigned int		end_state;
 	int			*start_type;
+	char			arg_name[16];
 	int			arg_cnt;
 };
 
@@ -957,7 +960,15 @@ static char *new_arg(struct tracefs_synth *synth)
 	char *arg;
 	int ret;
 
-	ret = asprintf(&arg, "__arg__%d", cnt);
+	/* Create a unique argument name */
+	if (!synth->arg_name[0]) {
+		srand(time(NULL));
+		ret = rand() + gettid();
+		/* Truncate so that ret is at most 65535 (total 13 bytes) */
+		ret &= (1 << 16) - 1;
+		sprintf(synth->arg_name, "__arg_%d_", ret);
+	}
+	ret = asprintf(&arg, "%s%d", synth->arg_name, cnt);
 	if (ret < 0)
 		return NULL;
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ