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

IPv6: Avoid uninitialized ifp state when adding address #395

Merged
merged 1 commit into from
Oct 29, 2024
Merged

IPv6: Avoid uninitialized ifp state when adding address #395

merged 1 commit into from
Oct 29, 2024

Conversation

kensimon
Copy link
Contributor

In certain instances, ifp->if_data[IF_DATA_IPV6] was not yet initialized when ipv6_addaddr adds the address to the state, and a segfault would ensue. Mitigate this by ensuring the state is initialized when adding the addresses.

fixes #394

In certain instances, `ifp->if_data[IF_DATA_IPV6]` was not yet
initialized when ipv6_addaddr adds the address to the state, and a
segfault would ensue. Mitigate this by ensuring the state is initialized
when adding the addresses.

fixes #394
@kensimon
Copy link
Contributor Author

This fixes #394 for me... I'm not sure why the ifp data is not yet initialized at this point. It's possible that's the bigger issue, but I don't have the expertise to find out why...

@rsmarples
Copy link
Member

Interesting. Nice diagnosis. Is wg(4) a PtP interface as reported by ifconfig? Does it have an IPv6 link-local address?

@kensimon
Copy link
Contributor Author

It doesn’t have a link local address, no… it’s a link-layer interface, basically a virtual interface. The address family is 18, AF_LINK in OpenBSD’s socket.h header.

I’m not at a computer now but I was looking at the code paths that will set up the state properly, and I found that for the rest of my interfaces, if_learnaddrs is calling ipv6_handleifa, which eventually calls if_getstate and initializes the state. But, if_learnaddrs only does this if the address family is AF_INET6, and since the wg0 interface is returning AF_LINK, the state remains uninitialized.

@rsmarples
Copy link
Member

I don't have a wireguard server to hand to test with, but all my other PtP interfaces do get a link-local address which is why I never had any issues. Your patch is good.

@rsmarples rsmarples merged commit e354743 into NetworkConfiguration:master Oct 29, 2024
@rsmarples
Copy link
Member

Thanks!

@kensimon kensimon deleted the fix-394 branch October 29, 2024 23:43
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.

Segfault on OpenBSD when configuring wireguard interface for prefix delegation
2 participants