trace-cmd: Fix segmentation fault in tracecmd_read_at() in specific use case
PATCH v2 1/1 trace-cmd: Fix segmentation fault in tracecmd_read_at() in specific use case
There is a segmentation fault in update_page_info() when the requested page is not loaded, handle->cpu_data[cpu].page is NULL. The problematic flow starts from tracecmd_read_at() API, when reading offset in the first page (less than 4K), and this page is still not loaded. The problem can be observed randomly - there is a sporadic KernelShark crash when loading a file, browsing and zooming events.
https://bugzilla.kernel.org/show_bug.cgi?id=205165
Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>
---
[
v2 changes:
- Moved the check for NULL page after the loop, as Steven Rostedt suggested.
]
lib/trace-cmd/trace-input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/trace-cmd/trace-input.c +1 -1
@@ -1282,7 +1282,7 @@ tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,break ; } -if (cpu < handle->cpus) { +if (cpu < handle->cpus && handle->cpu_data[cpu].page) {if (pcpu) *pcpu = cpu;return read_event (handle, offset, cpu);
Signature · 1 line
2.21.0