Skip to content

Commit c04d2f4

Browse files
committed
fix: accepting incoming tcp connection x86 Android
With Rust 1.49.0, accepting incoming connections on tcp sockets failed in different ways: Starting with Android Oreo (8), Android started using a seccomp based filter approach to syscalls, explicitly allowing syscalls, see https://android-developers.googleblog.com/2017/07/seccomp-filter-in-android-o.html. https://android.googlesource.com/platform/bionic.git/+/master/libc/SYSCALLS.TXT enumerates the allowed syscalls. rust-lang/rust#78572 refactored the way `std::net::TcpListener` accepts incoming connections on tcp sockets. With the seccomp profile above, doing a generic syscall will result in a panic: ``` [..] 02-22 13:14:23.288 6015 6041 F my.app.DEBUG: signal 31 (SIGSYS), code 1 (SYS_SECCOMP), fault addr -------- 02-22 13:14:23.288 6015 6041 F my.app.DEBUG: Cause: seccomp prevented call to disallowed x86 system call 364 02-22 13:14:23.289 6015 6041 F my.app.DEBUG: Abort message: 'Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 4784 (tokio-runtime-w), pid 4735 (ground_services)' ``` On top of that, I found that older versions of Android, such as Android 6 (our Zebra ET50), will return Function not implemented (os error 38) for this syscall. My tests showed that this only happens on x86, although I can't explain why. Relevant strace: ``` [pid 10918] syscall_364(0x34, 0x9d5c9cf8, 0x9d5c9ca0, 0x80800, 0x9fda9dc8, 0x9fda9dc8 <unfinished ...> [pid 10918] <... syscall_364 resumed> ) = -1 (errno 38) ``` I have tested this with both real devices as well as Android emulators. We have been using the `async-io` based `libp2p::tcp::TcpConfig` so far, which used `std::net::TcpListener` under the hood. This commit also switches to using `libp2p::tcp::TokioTcpConfig`. Now, tokio uses mio, which doesn't use `std::net::TcpListener` but raw sockets directly. Recently, a workaround for the erroneous behaviour described above was merged to mio, which is still pending to be released on crates.io (tokio-rs/mio#1462). Once tokio uses the updated mio version, we should move back to the crates.io provided version. For tracking the issue in `std::net::TcpListener`, I created rust-lang/rust#82400.
1 parent 9237d85 commit c04d2f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ futures = { version = "0.3.12", package = "futures" }
1313
serde = { version = "1.0.123", features = ["derive"] }
1414
serde_json = { version = "1.0.61", features = ["raw_value"] }
1515
bytes = "1.0.1"
16-
tokio = { version = "1.1.0", features = ["full"], package = "tokio" }
16+
tokio = { version = "1.2.0", features = ["full"], package = "tokio" }
1717
tracing = "0.1.22"
1818
tracing-futures = "0.2.4"
1919
actyxos_sdk = { path = "../../rust/sdk" }

0 commit comments

Comments
 (0)