Skip to content

Commit d398cba

Browse files
authored
fix(backend): use epoll on Android — io_uring is blocked by seccomp (#215)
Android blocks io_uring syscalls via seccomp-bpf, so it cannot be used on real devices. Default to epoll when targeting Android. Ref: https://security.googleblog.com/2023/06/learnings-from-kctf-vrps-42-linux.html
2 parents 7e7d2f2 + 19188df commit d398cba

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/backend.zig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ pub const Backend = enum {
1212
/// Returns a recommend default backend from inspecting the system.
1313
pub fn default() Backend {
1414
return switch (builtin.os.tag) {
15-
.linux => .io_uring,
15+
.linux => if (builtin.abi.isAndroid())
16+
.epoll
17+
else
18+
.io_uring,
1619
.ios, .macos, .visionos => .kqueue,
1720
.freebsd => .kqueue,
1821
.wasi => .wasi_poll,
@@ -27,7 +30,10 @@ pub const Backend = enum {
2730
/// Candidate backends for this platform in priority order.
2831
pub fn candidates() []const Backend {
2932
return switch (builtin.os.tag) {
30-
.linux => &.{ .io_uring, .epoll },
33+
.linux => if (builtin.abi.isAndroid())
34+
&.{.epoll}
35+
else
36+
&.{ .io_uring, .epoll },
3137
.ios, .macos, .visionos => &.{.kqueue},
3238
.freebsd => &.{.kqueue},
3339
.wasi => &.{.wasi_poll},

0 commit comments

Comments
 (0)