meh / rust-tun

TUN device creation and handling.
345 stars 139 forks source link

Drop Fd crash in Android 11 #51

Open Rosario9527 opened 1 year ago

Rosario9527 commented 1 year ago

Hi, raw_fd created by Android VpnService establish(), pass raw_fd to rust tun, When shutdown tun, drop fd libc::close invoked automatically, and Android 11 Crashed A/libc: fdsan: attempted to close file descriptor 68, expected to be unowned, actually owned by ParcelFileDescriptor 0xa381657

it's not allowed close with no tag in Android 11 or higher. add a option to close raw_fd manually: PR HERE

ref: fdsan, android_fdsan_close_with_tag and close

mokhtarabadi commented 1 year ago

Test [detachFd()](https://developer.android.com/reference/android/os/ParcelFileDescriptor#detachFd())