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 errors detected by fdscan to improve user-perceived crash rate #886

Closed
wants to merge 4 commits into from

Conversation

atavism
Copy link
Contributor

@atavism atavism commented Jul 24, 2023

For https://github.com/getlantern/engineering/issues/201

fdsan is a file descriptor sanitizer added to Android in API level 29. It detects mishandling of file descriptor ownership, which tends to manifest as use-after-close and double-close errors.

In the GoTun2SocksProvider class, we use VpnService.Builder.establish() to create the TUN device and return a file descriptor the application uses to access IP packets on it. tun2socks takes ownership of this file descriptor and closes it whenever ipproxy is stopped.

However, whenever the VPN is turned off, we are also calling ParcelFileDescriptor.close(). Given the fd is already closed, fdscan complains that we're double closing it. By calling detachFd instead of getFd, we can detach the file descriptor from the ParcelFileDescriptor object

@atavism
Copy link
Contributor Author

atavism commented Aug 28, 2023

Closing this in favor of #890

@atavism atavism closed this Aug 28, 2023
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.

1 participant