diff options
author | 2020-02-18 12:34:15 -0800 | |
---|---|---|
committer | 2020-02-18 13:17:30 -0800 | |
commit | 6a2892c7685afb97dff6ad7b9a963065a106048d (patch) | |
tree | 1e6fc0ad6222f33983f2b4977da44781371a16fe /libs/cputimeinstate | |
parent | abecf0482c45d1b4deb1877b15cef15240b41fb5 (diff) |
libtimeinstate: open programs read-only
We only grant system_server read access to programs, but bpf_obj_get()
unnecessarily requests write as well. Instead, use bpfFdGet to open
the programs read-only
Test: programs are successfully opened & attached
Bug: 138317993
Change-Id: Icf6478737de7ea1272b995fdc7a5bd4e8947c10d
Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'libs/cputimeinstate')
-rw-r--r-- | libs/cputimeinstate/cputimeinstate.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libs/cputimeinstate/cputimeinstate.cpp b/libs/cputimeinstate/cputimeinstate.cpp index 05a462e026..a03775bdbf 100644 --- a/libs/cputimeinstate/cputimeinstate.cpp +++ b/libs/cputimeinstate/cputimeinstate.cpp @@ -156,7 +156,7 @@ static bool initGlobals() { static bool attachTracepointProgram(const std::string &eventType, const std::string &eventName) { std::string path = StringPrintf(BPF_FS_PATH "prog_time_in_state_tracepoint_%s_%s", eventType.c_str(), eventName.c_str()); - int prog_fd = bpf_obj_get(path.c_str()); + int prog_fd = bpfFdGet(path.c_str(), BPF_F_RDONLY); if (prog_fd < 0) return false; return bpf_attach_tracepoint(prog_fd, eventType.c_str(), eventName.c_str()) >= 0; } |