BpfRingbuf.h - use exclusively locked map
As currently implemented, it is not safe to open (and mmap) the
same kernel -> userspace ringbuffer multiple times.
Note: it's likely, that as implemented, even a single instance
is not thread safe without external locking.
Test: TreeHugger, atest bpf_existence_test bpf_module_test bpf-time-in-state-tests libbpf_android_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iea6908746a58e7412c0ce89da29a764aefeaef47
diff --git a/staticlibs/native/bpf_headers/include/bpf/BpfRingbuf.h b/staticlibs/native/bpf_headers/include/bpf/BpfRingbuf.h
index d716358..cd51004 100644
--- a/staticlibs/native/bpf_headers/include/bpf/BpfRingbuf.h
+++ b/staticlibs/native/bpf_headers/include/bpf/BpfRingbuf.h
@@ -151,7 +151,7 @@
inline base::Result<void> BpfRingbufBase::Init(const char* path) {
- mRingFd.reset(mapRetrieveRW(path));
+ mRingFd.reset(mapRetrieveExclusiveRW(path));
if (!mRingFd.ok()) {
return android::base::ErrnoError()
<< "failed to retrieve ringbuffer at " << path;