Skip to content

Commit

Permalink
syms: Initialize ModulePath::fd_ to invalid FD
Browse files Browse the repository at this point in the history
~ModulePath() does `if (fd_ > 0) close fd_;`. But ModulePath constructor
has early return codepath for `!enter_ns` which does not initialize
`fd_`.

So `fd_` can potentially have junk value. That junk value could be any
FD downstream. bcc cannot be closing random FDs.
  • Loading branch information
danobi committed Jan 17, 2025
1 parent fea5b15 commit 67472f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cc/syms.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ProcSyms : SymbolCache {
// process by storing a file descriptor created from openat(2) if possible
// if openat fails, falls back to process-dependent path with /proc/.../root
private:
int fd_;
int fd_ = -1;
std::string proc_root_path_;
std::string path_;

Expand Down

0 comments on commit 67472f4

Please sign in to comment.