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

recvmmsg is disallowed by seccomp on Android x86 #1947

Closed
mxinden opened this issue Jul 31, 2024 · 5 comments
Closed

recvmmsg is disallowed by seccomp on Android x86 #1947

mxinden opened this issue Jul 31, 2024 · 5 comments

Comments

@mxinden
Copy link
Collaborator

mxinden commented Jul 31, 2024

What happened

We attempted switching Firefox Nightly to use quinn-udp for QUIC UDP I/O by default recently, though we had to roll back due to an error on Android x86. Investigating further, it seems like seccomp on Android x86 disallows sendmsg and recvmmsg. All details are in Bugzilla Bug 1910594 and 1910360.

Reasoning

Looking at e.g. Android 13's SYSCALLS.TXT we can see support for sendmsg and recvmmsg on 64bit (lp64) and ARM:

# sockets
// [...]
ssize_t       __sendmsg:sendmsg(int, const struct msghdr*, unsigned int)  arm,lp64
// [...]
int           __recvmmsg:recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*)   arm,lp64

While on x86, only the indirect calls through socketcall are allowed:

# sockets for x86. These are done as an "indexed" call to socketcall syscall.
// [...]
int           __sendmsg:socketcall:16(int, const struct msghdr*, unsigned int)  x86
// [...]
int           __recvmmsg:socketcall:19(int, struct mmsghdr*, unsigned int, int, const struct timespec*)   x86

Potential Solution

libuv has faced the same issue (see libuv/libuv#2923). On x86 they use the indirect syscalls through socketcall (see libuv/libuv#2925).

Historical context

The above might be due to historical reasons:

On x86-32, socketcall() was historically the only entry point for
the sockets API. However, starting in Linux 4.3, direct system
calls are provided on x86-32 for the sockets API.

https://man7.org/linux/man-pages/man2/socketcall.2.html


I still have to investigate a bit before proposing a fix. Opening this issue early to track progress.

@Ralith
Copy link
Collaborator

Ralith commented Jul 31, 2024

That's a weird one. Can we push for a fix upstream? Bearing mind that we'll need to work around the issue on older devices anyway.

@djc
Copy link
Member

djc commented Jul 31, 2024

That's a weird one. Can we push for a fix upstream? Bearing mind that we'll need to work around the issue on older devices anyway.

By upstream, do you mean Android? If so, Android 13 is from 2022 so I'm assuming they'll be reluctant to put in fixes like this.

@Ralith
Copy link
Collaborator

Ralith commented Aug 1, 2024

By upstream, do you mean Android?

Right.

Android 13 is from 2022 so I'm assuming they'll be reluctant to put in fixes like this.

I couldn't guess either way, but it's not clear from the description if this has already been fixed in newer Android versions. Would be nice to make things less bad in the future, if not.

@mxinden
Copy link
Collaborator Author

mxinden commented Aug 1, 2024

Can we push for a fix upstream?

Intuitively I don't expect that such a pervasive change to a systems default seccomp filters on an ancient platform like Android x86 would be accepted. That said, I don't have any experience interacting with these projects.

For comparison, next to libuv mentioned above, here is what mio and Rust's libc did. The same problem applies not only to sendmsg and to recvmmsg but also to the accept system call family. While accept is supported on Android x86, accept4 is disallowed by seccomp.

Android 13 is from 2022 so I'm assuming they'll be reluctant to put in fixes like this.

I couldn't guess either way, but it's not clear from the description if this has already been fixed in newer Android versions. Would be nice to make things less bad in the future, if not.

As far as I can tell, it is not fixed in the most recent Android version, that is Android 14. See recvmmsg call once defined for arm and lp64 and once for x86 in SYSCALLS.TXT.

@mxinden
Copy link
Collaborator Author

mxinden commented Sep 3, 2024

With #1966 merged and released, this is fixed. 😮‍💨

As always, thank you for your help Dirkjan and Benjamin!

@mxinden mxinden closed this as completed Sep 3, 2024
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Oct 31, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 1, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890

UltraBlame original commit: 768c0cdc9453e75f3adca22194c725f78d314cf2
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 1, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890

UltraBlame original commit: 768c0cdc9453e75f3adca22194c725f78d314cf2
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 1, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890

UltraBlame original commit: 768c0cdc9453e75f3adca22194c725f78d314cf2
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Nov 1, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 5, 2024
…ply-chain-reviewers,sunil

https://bugzilla.mozilla.org/show_bug.cgi?id=1910360 replaced NSPR with
quinn-udp for HTTP3 QUIC UDP IO on Firefox Nightly. Calls to `recvmmsg` were
prohibited by seccomp on Android x86. See
https://bugzilla.mozilla.org/show_bug.cgi?id=1910594, upstream quinn-udp
tracking issue: quinn-rs/quinn#1947 and upstream
quinn-udp fix: quinn-rs/quinn#1966

Now that the upstream fix is merged and released, this commit upgrads neqo_glue
to use quinn-udp `v0.5.6`. In addition, given the fix, quinn-udp can now be used
on Android x86 Firefox Nightly. Thus this commit also removes the conditional
around the `network.http.http3.use_nspr_for_io` pref.

Differential Revision: https://phabricator.services.mozilla.com/D220890
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 a pull request may close this issue.

3 participants