alistair23-linux/kernel/trace
Marcin Slusarz 1aa54bca6e tracing: Sanitize value returned from write(trace_marker, "...", len)
When userspace code writes non-new-line-terminated string to trace_marker
file, write handler appends new-line and returns number of bytes written
to trace buffer, so
write(fd, "abc", 3) will return 4

That's unexpected and unfortunately it confuses glibc's fprintf function.

Example:
int main() {
  fprintf(stderr, "abc");
  return 0;
}

$ gcc test.c -o test
$ echo mmiotrace > /sys/kernel/debug/tracing/current_tracer
$ ./test 2>/sys/kernel/debug/tracing/trace_marker

results in infinite loop:
write(fd, "abc", 3) = 4
write(fd, "", 1) = 0
write(fd, "", 1) = 0
write(fd, "", 1) = 0
write(fd, "", 1) = 0
write(fd, "", 1) = 0
write(fd, "", 1) = 0
write(fd, "", 1) = 0
(...)

...and kernel trace buffer full of empty markers.

Fix it by sanitizing write return value.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
LKML-Reference: <20100727231801.GB2826@joi.lan>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-08-13 15:23:16 -04:00
..
blktrace.c blktrace: Fix new kernel-doc warnings 2010-05-31 09:58:20 +02:00
ftrace.c Merge branch 'tracing-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-18 08:35:04 -07:00
Kconfig x86, perf, bts, mm: Delete the never used BTS-ptrace code 2010-03-26 11:33:55 +01:00
kmemtrace.c tracing: Allow events to share their print functions 2010-05-14 14:20:32 -04:00
Makefile x86, perf, bts, mm: Delete the never used BTS-ptrace code 2010-03-26 11:33:55 +01:00
power-traces.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
ring_buffer.c tracing: Fix ring_buffer_read_page reading out of page boundary 2010-08-06 14:34:45 -04:00
ring_buffer_benchmark.c ring-buffer: Make benchmark handle missed events 2010-04-27 13:26:58 -04:00
trace.c tracing: Sanitize value returned from write(trace_marker, "...", len) 2010-08-13 15:23:16 -04:00
trace.h Merge branch 'tracing-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-18 08:35:04 -07:00
trace_boot.c
trace_branch.c tracing: Allow events to share their print functions 2010-05-14 14:20:32 -04:00
trace_clock.c tracing: Fix lockdep warning in global_clock() 2010-03-29 15:16:44 -04:00
trace_entries.h x86, perf, bts, mm: Delete the never used BTS-ptrace code 2010-03-26 11:33:55 +01:00
trace_event_perf.c perf/tracing: Fix regression of perf losing kprobe events 2010-06-10 20:56:54 -04:00
trace_events.c tracing/events: Convert format output to seq_file 2010-08-12 16:59:29 -04:00
trace_events_filter.c Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip into trace/tip/tracing/core-6 2010-05-18 00:35:23 -04:00
trace_export.c tracing: Remove duplicate id information in event structure 2010-05-14 14:33:15 -04:00
trace_functions.c
trace_functions_graph.c tracing: Fix an unallocated memory access in function_graph 2010-08-06 12:19:15 -04:00
trace_irqsoff.c tracing: Add graph output support for irqsoff tracer 2010-04-27 12:36:53 -04:00
trace_kprobe.c perf_events, trace: Fix probe unregister race 2010-05-31 08:46:09 +02:00
trace_ksym.c hw-breakpoints: Get the number of available registers on boot dynamically 2010-05-01 04:32:14 +02:00
trace_mmiotrace.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
trace_nop.c
trace_output.c Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-27 15:23:47 -07:00
trace_output.h tracing: Allow events to share their print functions 2010-05-14 14:20:32 -04:00
trace_printk.c
trace_sched_switch.c tracing: Let tracepoints have data passed to tracepoint callbacks 2010-05-14 09:50:34 -04:00
trace_sched_wakeup.c tracing: Let tracepoints have data passed to tracepoint callbacks 2010-05-14 09:50:34 -04:00
trace_selftest.c Merge branch 'tracing-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-05-18 08:35:04 -07:00
trace_selftest_dynamic.c
trace_stack.c
trace_stat.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
trace_stat.h
trace_syscalls.c perf_events, trace: Fix probe unregister race 2010-05-31 08:46:09 +02:00
trace_sysprof.c
trace_workqueue.c tracing: Let tracepoints have data passed to tracepoint callbacks 2010-05-14 09:50:34 -04:00