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, 27 Aug 2009 18:42:06 +0800
From:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
To:	Ingo Molnar <mingo@...e.hu>
CC:	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Wei Yongjun <yjwei@...fujitsu.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] tracing/events: parameter check for __string() and *_str()

If we pass a NULL pointer to __string() and *_str(), kernel will
crash, this patch stop it and print the NULL pointer to user, for
example:

sshd-2545  [000]    95.588404: napi_poll: ifname=<NULL>

Signed-off-by: Xiao Guangrong <xiaoguangrong@...fujitsu.com>
---
 include/trace/ftrace.h             |   11 +++++++----
 kernel/trace/trace_events_filter.c |    2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 360a77a..036aa0e 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -229,8 +229,9 @@ ftrace_format_##call(struct ftrace_event_call *unused,			\
 #define TP_printk(fmt, args...) fmt "\n", args
 
 #undef __get_dynamic_array
-#define __get_dynamic_array(field)	\
-		((void *)__entry + (__entry->__data_loc_##field & 0xffff))
+#define __get_dynamic_array(field)					\
+	((__entry->__data_loc_##field & 0xffff0000) ?			\
+	((void *)__entry + (__entry->__data_loc_##field & 0xffff)) : NULL)
 
 #undef __get_str
 #define __get_str(field) (char *)__get_dynamic_array(field)
@@ -357,7 +358,8 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call)	\
 	__data_size += (len) * sizeof(type);
 
 #undef __string
-#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)       \
+#define __string(item, src)						\
+	__dynamic_array(char, item, src ? strlen(src) + 1 : 0)
 
 #undef TRACE_EVENT
 #define TRACE_EVENT(call, proto, args, tstruct, assign, print)		\
@@ -554,7 +556,8 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
 
 #undef __assign_str
 #define __assign_str(dst, src)						\
-	strcpy(__get_str(dst), src);
+	if (src) 							\
+		strcpy(__get_str(dst), src);
 
 #undef TRACE_EVENT
 #define TRACE_EVENT(call, proto, args, tstruct, assign, print)		\
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 9f03082..9f1838a 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -196,7 +196,7 @@ static int filter_pred_strloc(struct filter_pred *pred, void *event,
 	char *addr = (char *)(event + str_loc);
 	int cmp, match;
 
-	cmp = strncmp(addr, pred->str_val, str_len);
+	cmp = str_len ? strncmp(addr, pred->str_val, str_len) : -1;
 
 	match = (!cmp) ^ pred->not;
 
-- 
1.6.1.2


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