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

fix(aya-sock-map): invalid transmute when calling fd #880

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

erebe
Copy link
Contributor

@erebe erebe commented Feb 7, 2024

Corrent an invalid transmutation for sock_map.
fd is already a ref of MapFd, so transmuting &fd to &SockMapFd is equivalent to transmuting &&SockMapFd into &SockMapFd which is buggy.

Step to reproduce

This simple program terminates in error with Os error 9, invalid file descriptor

    let mut intercept_ingress: SockMap<_> = bpf.take_map("INTERCEPT_INGRESS").unwrap().try_into()?;
    let map_fd = intercept_ingress.fd().try_clone()?;

SockHash is doing it correctly BTW https://github.com/aya-rs/aya/blob/main/aya/src/maps/sock/sock_hash.rs#L113

Copy link

netlify bot commented Feb 7, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 061ee08
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/65c338f10f703c0008cf8060
😎 Deploy Preview https://deploy-preview-880--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.

Corrent an invalid transmutation for sock_map.
fd is already a ref of MapFd, so transmuting &fd to &SockMapFd is
equivalent to transmuting &&SockMapFd into &SockMapFd which is buggy.
@mergify mergify bot added the aya This is about aya (userspace) label Feb 7, 2024
Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

Oops, nice catch and thanks for the PR!

@erebe
Copy link
Contributor Author

erebe commented Feb 7, 2024

You welcome, thanks for aya :)

@alessandrod alessandrod merged commit c31cce4 into aya-rs:main Feb 7, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants