Commit e38da59269be8c0196d16dff1be5bb26076afc6a

Authored by Török Edwin
Committed by Ingo Molnar
1 parent 8d26487fd4

tracing/stack-tracer: avoid races accessing file

Impact: fix race

vma->vm_file reference is only stable while holding the mmap_sem,
so move usage of it to within the critical section.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff

kernel/trace/trace.c
... ... @@ -1470,12 +1470,12 @@
1470 1470 file = vma->vm_file;
1471 1471 vmstart = vma->vm_start;
1472 1472 }
  1473 + if (file) {
  1474 + ret = trace_seq_path(s, &file->f_path);
  1475 + if (ret)
  1476 + ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart);
  1477 + }
1473 1478 up_read(&mm->mmap_sem);
1474   - }
1475   - if (file) {
1476   - ret = trace_seq_path(s, &file->f_path);
1477   - if (ret)
1478   - ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart);
1479 1479 }
1480 1480 if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
1481 1481 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);