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

Backport commits to 0.7.x branch #1462

Closed
wngr opened this issue Feb 22, 2021 · 4 comments
Closed

Backport commits to 0.7.x branch #1462

wngr opened this issue Feb 22, 2021 · 4 comments

Comments

@wngr
Copy link

wngr commented Feb 22, 2021

Hello,

I have hit a critical issue for our use case using tokio > 1.0, which is based on mio 0.7.6: Using the accept4 syscall on Android x86 fails, either by being blocked through seccomp on more recent Android versions, but failing with Err 38: Function not implemented on Android 6 on real devices.

I wonder whether it would be possible to backport 40159fa and 4c4e919 and release a new version with that, .. and get it integrated into tokio.

Not sure what the tokio's project stance is on such matters.

@Thomasdezeeuw
Copy link
Collaborator

I've opened #1463, with that we can release v0.7.9 and after a cargo update everything should be working.

@Thomasdezeeuw
Copy link
Collaborator

I would also like to backport #1461, after that we can create a new release.

@wngr
Copy link
Author

wngr commented Feb 22, 2021

Great, thanks!

@Thomasdezeeuw
Copy link
Collaborator

Just released v0.7.9.

aruediger pushed a commit to Actyx/wsrpc that referenced this issue Mar 12, 2021
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.
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

No branches or pull requests

2 participants