[Bug 277118] Linux Emulation (Linuxulator): accept(2) does not time out, SO_RCVTIMEO is ignored
Date: Sat, 17 Feb 2024 19:07:27 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277118
Bug ID: 277118
Summary: Linux Emulation (Linuxulator): accept(2) does not time
out, SO_RCVTIMEO is ignored
Product: Base System
Version: 14.0-STABLE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: christian@kohlschutter.com
Attachment #248545 text/plain
mime type:
Created attachment 248545
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=248545&action=edit
Code demonstrating the bug (compile with/for Linux, then test on Linux, and use
Linuxulator to test on FreeBSD)
In Linux, setting SO_RCVTIMEO on a listening, blocking socket will cause
accept(2) to return with -1 and errno=EAGAIN.
Linuxulator unfortunately does not mimic this behavior, and instead exposes BSD
behavior (timeout is ignored). Therefore, any Linux code relying on the timeout
may fail to work correctly with FreeBSD Linux emulation.
This can be fixed in a way compatible with Linux proper and FreeBSD Linuxulator
(if source code access is available) by calling poll(2) prior to accept(2).
However, code that is optimized for Linux proper should not require the call to
poll(2) just to support the niche use case of supporting Linuxulator on
FreeBSD, as that would increase the number of syscalls when running the binary
on Linux proper.
A small test case is attached.
--
You are receiving this mail because:
You are the assignee for the bug.