-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys: bpf_prog_get_fd_by_id returns OwnedFd #688
Conversation
✅ Deploy Preview for aya-rs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
I added this to #637 so either merge that and close this or vice versa
} | ||
|
||
Ok(prog_fds | ||
.into_iter() | ||
.map(|prog_fd| LircLink::new(prog_fd, target_fd.as_raw_fd())) | ||
.map(|prog_fd| LircLink::new(prog_fd.into_raw_fd(), target_fd.as_raw_fd())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is already merged but the OwnedFd
is dropped here since there are no other usages of OwnedFd
and thus the file descriptor is closed and yet we are creating a LircLink
with this closed file descriptor. LircLink
has a method info
that uses this file descriptor to get its program information but that file descriptor is now closed. I don't really use lirc probes so I am not how how to test/prove that but I figured it's worth calling out that this PR most likely broke getting the program information from a queried list of lirc programs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp nvm, I thought we were calling for as_raw_fd
. Ignore
@@ -955,7 +955,7 @@ impl ProgramInfo { | |||
call: "bpf_prog_get_fd_by_id", | |||
io_error, | |||
})?; | |||
Ok(fd as RawFd) | |||
Ok(fd.into_raw_fd()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is another place that this PR probably broke things. The fd
returned here is already closed because the OwnedFd
is dropped so anyone calling for this fd
is getting a bad file descriptor. Additionally, the comment of this method no longer makes sense:
/// The returned fd must be closed when no longer needed.
I think this would be a quick fix though, we just gotta make this function return an OwnedFd
instead and remove the comment since OwnedFd
s are closed on drop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp nvm, I thought we were calling for as_raw_fd
. Ignore
No description provided.