diff options
| author | David Daney <ddaney@caviumnetworks.com> | 2010-07-19 20:46:49 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-07-20 15:53:58 -0400 |
| commit | eb27e538a6a9ba97e3369135e12a808b9f4a192a (patch) | |
| tree | 64e1f2116a7ca6617890f81189edb5d60a3d4159 | |
| parent | 65d8d28cf443771acfc6bb09bf91422d351010b4 (diff) | |
trace-cmd: Don't try to read unmapped memory (v2).
Under some circumstances, I'm not sure exactly which, a trace.dat file
may contain a bunch of zeros at the end of one or more of the trace
logs. This can lead to tracecmd_peek_data() attempting to read past
the end of the mmaped log, causing SIGSEGV.
This is a two part fix.
1) For 'new format' data, we always try to read 8 bytes of data. Make
sure that they are all on the current page.
2) In pevent_print_event(), if record->size is negative, warn and then
skip attempting to print it.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
LKML-Reference: <1279586810-29859-2-git-send-email-ddaney@caviumnetworks.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | parse-events.c | 5 | ||||
| -rw-r--r-- | trace-input.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/parse-events.c b/parse-events.c index 9d5a3fa..1e854e2 100644 --- a/parse-events.c +++ b/parse-events.c | |||
| @@ -3881,6 +3881,11 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s, | |||
| 3881 | usecs = record->ts - secs * NSECS_PER_SEC; | 3881 | usecs = record->ts - secs * NSECS_PER_SEC; |
| 3882 | usecs = (usecs + 500) / NSECS_PER_USEC; | 3882 | usecs = (usecs + 500) / NSECS_PER_USEC; |
| 3883 | 3883 | ||
| 3884 | if (record->size < 0) { | ||
| 3885 | do_warning("ug! negative record size %d", record->size); | ||
| 3886 | return; | ||
| 3887 | } | ||
| 3888 | |||
| 3884 | type = trace_parse_common_type(pevent, data); | 3889 | type = trace_parse_common_type(pevent, data); |
| 3885 | 3890 | ||
| 3886 | event = pevent_find_event(pevent, type); | 3891 | event = pevent_find_event(pevent, type); |
diff --git a/trace-input.c b/trace-input.c index b3dbca3..7db5577 100644 --- a/trace-input.c +++ b/trace-input.c | |||
| @@ -1513,7 +1513,8 @@ read_again: | |||
| 1513 | if (index < 0) | 1513 | if (index < 0) |
| 1514 | die("negative index on cpu record %d", cpu); | 1514 | die("negative index on cpu record %d", cpu); |
| 1515 | 1515 | ||
| 1516 | if (index >= handle->cpu_data[cpu].page_size + pevent->header_page_data_offset) { | 1516 | if (index + (pevent->old_format ? 0 : 4) >= |
| 1517 | handle->cpu_data[cpu].page_size + pevent->header_page_data_offset) { | ||
| 1517 | if (get_next_page(handle, cpu)) | 1518 | if (get_next_page(handle, cpu)) |
| 1518 | return NULL; | 1519 | return NULL; |
| 1519 | return tracecmd_peek_data(handle, cpu); | 1520 | return tracecmd_peek_data(handle, cpu); |
