aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2018-01-11 19:47:46 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-01-17 08:22:08 -0500
commit37db96bb49629681cb839d7304a70524fe10f969 (patch)
tree3eae8bf095d1c639f9a8d91d35c15293f6cda6de /tools/lib
parent38d70b7ca1769f26c0b79f3c08ff2cc949712b59 (diff)
tools lib traceevent: Handle new pointer processing of bprint strings
The Linux kernel printf() has some extended use cases that dereference the pointer. This is dangerouse for tracing because the pointer that is dereferenced can change or even be unmapped. It also causes issues when the trace data is extracted, because user space does not have access to the contents of the pointer even if it still exists. To handle this, the kernel was updated to process these dereferenced pointers at the time they are recorded, and not post processed. Now they exist in the tracing buffer, and no dereference is needed at the time of reading the trace. The event parsing library needs to handle this new case. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/r/20180112004822.403349289@goodmis.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/traceevent/event-parse.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8757dd64e42c..344a034a8fbc 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4300,6 +4300,26 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
4300 goto process_again; 4300 goto process_again;
4301 case 'p': 4301 case 'p':
4302 ls = 1; 4302 ls = 1;
4303 if (isalnum(ptr[1])) {
4304 ptr++;
4305 /* Check for special pointers */
4306 switch (*ptr) {
4307 case 's':
4308 case 'S':
4309 case 'f':
4310 case 'F':
4311 break;
4312 default:
4313 /*
4314 * Older kernels do not process
4315 * dereferenced pointers.
4316 * Only process if the pointer
4317 * value is a printable.
4318 */
4319 if (isprint(*(char *)bptr))
4320 goto process_string;
4321 }
4322 }
4303 /* fall through */ 4323 /* fall through */
4304 case 'd': 4324 case 'd':
4305 case 'u': 4325 case 'u':
@@ -4352,6 +4372,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
4352 4372
4353 break; 4373 break;
4354 case 's': 4374 case 's':
4375 process_string:
4355 arg = alloc_arg(); 4376 arg = alloc_arg();
4356 if (!arg) { 4377 if (!arg) {
4357 do_warning_event(event, "%s(%d): not enough memory!", 4378 do_warning_event(event, "%s(%d): not enough memory!",
@@ -4959,6 +4980,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
4959 if (isalnum(ptr[1])) 4980 if (isalnum(ptr[1]))
4960 ptr++; 4981 ptr++;
4961 4982
4983 if (arg->type == PRINT_BSTRING) {
4984 trace_seq_puts(s, arg->string.string);
4985 break;
4986 }
4987
4962 if (*ptr == 'F' || *ptr == 'f' || 4988 if (*ptr == 'F' || *ptr == 'f' ||
4963 *ptr == 'S' || *ptr == 's') { 4989 *ptr == 'S' || *ptr == 's') {
4964 show_func = *ptr; 4990 show_func = *ptr;