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,  5 Feb 2015 19:56:39 +0000
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [RFC][PATCH 6/7] trace: constify filter_parse_regex(), match_records(), ftrace_match() and ftrace_match_record()

From: Al Viro <viro@...iv.linux.org.uk>

stop modifying the glob in there.

Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
 kernel/trace/ftrace.c              | 14 +++++++-------
 kernel/trace/trace.h               |  2 +-
 kernel/trace/trace_events_filter.c |  8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index e082681..572e3df 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3362,7 +3362,7 @@ ftrace_notrace_open(struct inode *inode, struct file *file)
 				 inode, file);
 }
 
-static int ftrace_match(char *str, char *regex, int len, int type)
+static int ftrace_match(char *str, const char *regex, int len, int type)
 {
 	int matched = 0;
 	int slen = strlen(str);
@@ -3417,7 +3417,7 @@ enter_record(struct ftrace_hash *hash, struct dyn_ftrace *rec, int not)
 
 static int
 ftrace_match_record(struct dyn_ftrace *rec, char *mod,
-		    char *regex, int len, int type)
+		    const char *regex, int len, int type)
 {
 	char str[KSYM_SYMBOL_LEN];
 	char *modname;
@@ -3438,13 +3438,13 @@ ftrace_match_record(struct dyn_ftrace *rec, char *mod,
 }
 
 static int
-match_records(struct ftrace_hash *hash, char *buff,
+match_records(struct ftrace_hash *hash, const char *buff,
 	      int len, char *mod, int not)
 {
 	struct ftrace_page *pg;
 	struct dyn_ftrace *rec;
 	int type = MATCH_FULL;
-	char *search = buff;
+	const char *search = buff;
 	int found = 0;
 	int ret;
 
@@ -3648,7 +3648,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
 	int type, len = strlen(glob), not;
 	unsigned long key;
 	int count = 0;
-	char *search;
+	const char *search;
 	int ret;
 
 	type = filter_parse_regex(glob, &len, &search, &not);
@@ -3759,7 +3759,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
 	char str[KSYM_SYMBOL_LEN];
 	int type = MATCH_FULL;
 	int i, len = 0;
-	char *search;
+	const char *search;
 	int ret;
 
 	if (glob && (strcmp(glob, "*") == 0 || !strlen(glob)))
@@ -4550,7 +4550,7 @@ ftrace_set_func(unsigned long *array, int *idx, int size, char *buffer)
 	int search_len = strlen(buffer);
 	int fail = 1;
 	int type, not;
-	char *search;
+	const char *search;
 	bool exists;
 	int i;
 
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 7483205..09279c5 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1051,7 +1051,7 @@ struct filter_pred {
 };
 
 extern enum regex_type
-filter_parse_regex(char *buff, int *len, char **search, int *not);
+filter_parse_regex(const char *buff, int *len, const char **search, int *not);
 extern void print_event_filter(struct ftrace_event_file *file,
 			       struct trace_seq *s);
 extern int apply_event_filter(struct ftrace_event_file *file,
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 6a659e1..5cefdd8 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -321,7 +321,8 @@ static int regex_match_end(char *str, struct regex *r, int len)
  *  not returns 1 if buff started with a '!'
  *     0 otherwise.
  */
-enum regex_type filter_parse_regex(char *buff, int *len, char **search, int *not)
+enum regex_type filter_parse_regex(const char *buff, int *len,
+				   const char **search, int *not)
 {
 	int type = MATCH_FULL;
 	int i;
@@ -345,12 +346,11 @@ enum regex_type filter_parse_regex(char *buff, int *len, char **search, int *not
 					type = MATCH_MIDDLE_ONLY;
 				else
 					type = MATCH_FRONT_ONLY;
-				buff[i] = 0;
 				break;
 			}
 		}
 	}
-	*len = strlen(*search);
+	*len = buff + i - *search;
 
 	return type;
 }
@@ -358,7 +358,7 @@ enum regex_type filter_parse_regex(char *buff, int *len, char **search, int *not
 static void filter_build_regex(struct filter_pred *pred)
 {
 	struct regex *r = &pred->regex;
-	char *search;
+	const char *search;
 	enum regex_type type = MATCH_FULL;
 	int not = 0;
 
-- 
2.1.4

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