Skip to content
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

Merged
merged 1 commit into from
Jul 26, 2023
Merged

sys: bpf_prog_get_fd_by_id returns OwnedFd #688

merged 1 commit into from
Jul 26, 2023

Conversation

tamird
Copy link
Member

@tamird tamird commented Jul 25, 2023

No description provided.

@tamird tamird requested a review from astoycos July 25, 2023 23:06
@netlify
Copy link

netlify bot commented Jul 25, 2023

Deploy Preview for aya-rs-docs ready!

Name Link
🔨 Latest commit 76c78e3
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/64c05a20d0e05f0008b18000
😎 Deploy Preview https://deploy-preview-688--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@astoycos astoycos left a 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

@tamird tamird merged commit 53d36a3 into main Jul 26, 2023
19 checks passed
@tamird tamird deleted the get-fd-owned branch July 26, 2023 17:31
}

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()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tamird

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.

Copy link
Contributor

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())
Copy link
Contributor

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 OwnedFds are closed on drop.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants