IPv6: Avoid uninitialized ifp state when adding address#395
IPv6: Avoid uninitialized ifp state when adding address#395rsmarples merged 1 commit intoNetworkConfiguration:masterfrom kensimon:fix-394
Conversation
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
|
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... |
|
Interesting. Nice diagnosis. Is wg(4) a PtP interface as reported by ifconfig? Does it have an IPv6 link-local address? |
|
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. |
|
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. |
|
Thanks! |
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