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

Misaligned pointer dereference in safe functions backend::channel and sockaddr_to_network_addr #648

Open
shinmao opened this issue Sep 21, 2023 · 0 comments

Comments

@shinmao
Copy link

shinmao commented Sep 21, 2023

The source of unsoundness

Hi, we consider that casting from sa_family to c_int would break the alignment requirement because the first one is aligned to 2 bytes while the later one is aligned to 4 bytes. Consider following two functions:

send_addr: unsafe { *(send_addr as *const libc::sockaddr_ll) },

} else if (*sa).sa_family as libc::c_int == libc::AF_PACKET {
let sll: *const libc::sockaddr_ll = mem::transmute(sa);

send_addr is also aligned to the bytes of sa_family, and it could lead to undefined behavior in safe function

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

No branches or pull requests

1 participant