-
Yonghong Song authored
Fix issue #1533. Currently, there exist a race condition between perf_reader buffer munmap and read if they are happening in two different threads, crash is possible as in issue #1533. thread 1 thread 2 perf_reader_event_read ... detach_probe munmap access ring buffer detach_probe may happen as part of bpf object exit cleanup process at which point thread 1 is still alive. In this case, accessing ring buffer may cause segfault since the original mmap'ed memory is not available any more. It is hard to fix such races outside bcc since user calls kprobe_poll which has valid BPF object when it is called, but race happens inside the kprobe_poll. This patch adds a state of the ring buffer and the read will not happen once the state comes to the munmap. Signed-off-by: Yonghong Song <yhs@fb.com>
cd5d4a6c