pendulum-project / timestamped-socket

An asynchronous UDP socket that supports timestamping
Other
8 stars 5 forks source link

Segfault in timestamped-socket #15

Closed dsseng closed 9 months ago

dsseng commented 9 months ago

Segfault by null pointer dereference at src/interface.rs:89:31, on both a PC with openSUSE Tumbleweed and Raspberry Pi 5 with Debian 12

rnijveld commented 9 months ago

Looks like ifa_addr in the ifaddrs struct might be null in some cases (i.e. the interface does not have an address for some reason), which we don't check for.

dsseng commented 9 months ago

Yes, it's null as per lldb debug. I couldn't fix that myself because I'm unsure what's the case. Interfaces have both IPv4 and IPv6 addresses.

teodly commented 9 months ago

It occurs when there is any interface without link address, e.g. VPN. It is indicated by link/none line in ip addr output.

Example:

$ ip a
[...]
38: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
    link/none 
    inet [...]/24 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::[...]/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
$ sudo killall openvpn

After stopping VPN, statime-linux started without crashing.

davidv1992 commented 9 months ago

Thank you for reporting and triaging this. I have gone over all the unsafe code in the crate again and the linked pull request should fix the issue, as well as provide proper reasoning for why all our unsafe code is valid now. Please let us know if you find any further issues.