Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a race condition during Android VPN service shutdown that could leave the TUN interface open, causing network traffic to be routed into a "black hole." The fix introduces a synchronized method for closing the TUN interface file descriptor and updates all call sites to use it.
Changes:
- Added a synchronized
closeTunInterface()method to safely close the TUN interface and prevent double-close from concurrent shutdown paths - Updated
onDestroy()to close TUN interface synchronously before cancelling the coroutine scope, preventing orphaned TUN interfaces - Replaced direct TUN interface operations in
postServiceClose()anddoStopVPN()with the new synchronized method
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jigar-f
approved these changes
Feb 17, 2026
atavism
added a commit
that referenced
this pull request
Feb 17, 2026
* Hide onboarding and datacap in ios (#8466) * Hide onboarding page and datacap in ios and update build number * code review updates * Garmr/ipc auth update (#8468) * pull in radiance changes * remove exclude arch in debug mode * Update to latest radiance with no DNSTT since its breaking stuff (#8470) * build and release updates (#8455) * add safe area in plans * Fix tablet upscaling and cap shared component sizing (#8457) * update design size for tablets * add cap scaling * update mintextadapt * logo updates and clean-ups * update text fields * clean-ups * clean-ups * fix scaling issue --------- Co-authored-by: Jigar-f <jigar@getlantern.org> * Fix for closing TUN (#8471) * Fix stage env toggle and store gating * Narrow followups to staging env * Enable Play store uploads for internal Android releases (#8467) * add support for internal Android releases * use correct name for internal track * update r0adkll/upload-google-play * Fix track name * update versionCode * update foreground service permission * disable exact alarm --------- Co-authored-by: jigar-f <132374182+jigar-f@users.noreply.github.com> Co-authored-by: garmr-ulfr <104022054+garmr-ulfr@users.noreply.github.com> Co-authored-by: Jigar-f <jigar@getlantern.org> Co-authored-by: Myles Horton <afisk@getlantern.org> Co-authored-by: Jay <110402935+jay-418@users.noreply.github.com>
jigar-f
added a commit
that referenced
this pull request
Feb 20, 2026
* work for stage env * update var name * use output var * set output * Update nightly.yml * try to use as env variable * Update build-macos.yml * update name * Remove stage for now & add default value * keep default and pass value * Simplify macos changes * Remove stage again * More debugging * compare it as string * added debug log * update radiance. * updated radiance * update radiance * use remote source * more stage changes * use radiance remote * Add stage env connection. * Revert workflows * generate ffi * use radiance remote and remove duplication logic * ran make format * use in app purchase for macos. * back to storekit one. * Switch to user on acknowledge purchase if found. * use new radiance. * update radiance. * do not clear all data * Harden stage environment toggle and env normalization (#8475) * Hide onboarding and datacap in ios (#8466) * Hide onboarding page and datacap in ios and update build number * code review updates * Garmr/ipc auth update (#8468) * pull in radiance changes * remove exclude arch in debug mode * Update to latest radiance with no DNSTT since its breaking stuff (#8470) * build and release updates (#8455) * add safe area in plans * Fix tablet upscaling and cap shared component sizing (#8457) * update design size for tablets * add cap scaling * update mintextadapt * logo updates and clean-ups * update text fields * clean-ups * clean-ups * fix scaling issue --------- Co-authored-by: Jigar-f <jigar@getlantern.org> * Fix for closing TUN (#8471) * Fix stage env toggle and store gating * Narrow followups to staging env * Enable Play store uploads for internal Android releases (#8467) * add support for internal Android releases * use correct name for internal track * update r0adkll/upload-google-play * Fix track name * update versionCode * update foreground service permission * disable exact alarm --------- Co-authored-by: jigar-f <132374182+jigar-f@users.noreply.github.com> Co-authored-by: garmr-ulfr <104022054+garmr-ulfr@users.noreply.github.com> Co-authored-by: Jigar-f <jigar@getlantern.org> Co-authored-by: Myles Horton <afisk@getlantern.org> Co-authored-by: Jay <110402935+jay-418@users.noreply.github.com> * Revert back some changes * Fix issue with stage * Fix stage issue on windows * update logs * revert back macos in app purchase changes --------- Co-authored-by: atavism <atavism@users.noreply.github.com> Co-authored-by: garmr-ulfr <104022054+garmr-ulfr@users.noreply.github.com> Co-authored-by: Myles Horton <afisk@getlantern.org> Co-authored-by: Jay <110402935+jay-418@users.noreply.github.com> Co-authored-by: atavism <paul@getlantern.org>
atavism
added a commit
that referenced
this pull request
Feb 20, 2026
* work for stage env * update var name * use output var * set output * Update nightly.yml * try to use as env variable * Update build-macos.yml * update name * Remove stage for now & add default value * keep default and pass value * Simplify macos changes * Remove stage again * More debugging * compare it as string * added debug log * update radiance. * updated radiance * update radiance * use remote source * more stage changes * use radiance remote * Add stage env connection. * Revert workflows * generate ffi * use radiance remote and remove duplication logic * ran make format * use in app purchase for macos. * back to storekit one. * Switch to user on acknowledge purchase if found. * use new radiance. * update radiance. * do not clear all data * Harden stage environment toggle and env normalization (#8475) * Hide onboarding and datacap in ios (#8466) * Hide onboarding page and datacap in ios and update build number * code review updates * Garmr/ipc auth update (#8468) * pull in radiance changes * remove exclude arch in debug mode * Update to latest radiance with no DNSTT since its breaking stuff (#8470) * build and release updates (#8455) * add safe area in plans * Fix tablet upscaling and cap shared component sizing (#8457) * update design size for tablets * add cap scaling * update mintextadapt * logo updates and clean-ups * update text fields * clean-ups * clean-ups * fix scaling issue --------- Co-authored-by: Jigar-f <jigar@getlantern.org> * Fix for closing TUN (#8471) * Fix stage env toggle and store gating * Narrow followups to staging env * Enable Play store uploads for internal Android releases (#8467) * add support for internal Android releases * use correct name for internal track * update r0adkll/upload-google-play * Fix track name * update versionCode * update foreground service permission * disable exact alarm --------- Co-authored-by: jigar-f <132374182+jigar-f@users.noreply.github.com> Co-authored-by: garmr-ulfr <104022054+garmr-ulfr@users.noreply.github.com> Co-authored-by: Jigar-f <jigar@getlantern.org> Co-authored-by: Myles Horton <afisk@getlantern.org> Co-authored-by: Jay <110402935+jay-418@users.noreply.github.com> * Revert back some changes * Fix issue with stage * Fix stage issue on windows * update logs * revert back macos in app purchase changes --------- Co-authored-by: atavism <atavism@users.noreply.github.com> Co-authored-by: garmr-ulfr <104022054+garmr-ulfr@users.noreply.github.com> Co-authored-by: Myles Horton <afisk@getlantern.org> Co-authored-by: Jay <110402935+jay-418@users.noreply.github.com> Co-authored-by: atavism <paul@getlantern.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes https://github.com/getlantern/engineering/issues/2997
This pull request improves the reliability and safety of shutting down the VPN service by adding a dedicated, synchronized method for closing the TUN interface file descriptor. This change helps prevent resource leaks and potential networking issues caused by the TUN interface remaining open due to race conditions during service shutdown.
Resource management and shutdown improvements:
closeTunInterfacemethod to safely and synchronously close the TUN interface file descriptor, ensuring it is not closed multiple times from concurrent shutdown paths.onDestroy,postServiceClose, anddoStopVPNto use the newcloseTunInterfacemethod instead of directly closing or nullifyingmInterface, preventing orphaned TUN interfaces and possible routing issues. [1] [2] [3]