3 ms·
The article doesn't mention that file descriptors "in flight" over sockets are garbage collected if the listening process doesn't pick them up. This has been t
by rwmj 6y ago
The article doesn't mention that file descriptors "in flight" over sockets are garbage collected if the listening process doesn't pick them up. This has been the subject of serveral bugs/security issues: https://nvd.nist.gov/vuln/detail/CVE-2008-5029 https://nvd.nist.gov/vuln/detail/CVE-2008-5029 https://lwn.net/Articles/779472/ https://lwn.net/Articles/779472/
Al Viro's description sums up one of the recent problems (which was fixed):
Among the features provided by io_uring is the ability to "register" one or more files with an open ring; that speeds I/O operations by eliminating the need to acquire and release references to the registered files every time. When a file is registered with an io_uring, the kernel will create and hold a reference for the duration of that registration. This is a useful feature but it contained a problem that, seemingly, only somebody with a Viro-level understanding of the VFS could spot, describe, and fix; it is a new variant on the cycle problem described above. In short: a process could create a Unix-domain socket and register both ends with an io_uring. If it were then to pass the file descriptor corresponding to the io_uring itself over that socket, then close all of the file descriptors, a cycle would be created. The io_uring code was unprepared for that eventuality.
- EdSchouten 6y agoThat's an interesting bug. Thanks for linking it here! Many flavours of UNIX have bugs in the area of file descriptor passing. The most recent one I spotted was that FreeBSD would leak file descriptors on the receiving side if the cmsg space was too small to hold all incoming file descriptors numbers. Another interesting one is that garbage collection of in-flight file descriptors is sometimes implemented by effectively calling close() recursively. This means that you can cause kernel panics due to kernel stack overflows by closing a socket pair that contains in-flight file descriptors of socket pairs that contain in-flight file descriptors of socket pairs that contain in-flight file descriptors of [...]