Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e38da592 authored by Török Edwin's avatar Török Edwin Committed by Ingo Molnar
Browse files

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: default avatarIngo Molnar <mingo@elte.hu>
parent 8d26487f
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -1470,13 +1470,13 @@ static inline int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
			file = vma->vm_file;
			file = vma->vm_file;
			vmstart = vma->vm_start;
			vmstart = vma->vm_start;
		}
		}
		up_read(&mm->mmap_sem);
	}
		if (file) {
		if (file) {
			ret = trace_seq_path(s, &file->f_path);
			ret = trace_seq_path(s, &file->f_path);
			if (ret)
			if (ret)
				ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart);
				ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart);
		}
		}
		up_read(&mm->mmap_sem);
	}
	if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
	if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
		ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
		ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
	return ret;
	return ret;