ELSEIF
Your brief EB
177 stories from 108 feeds 355 clusters Refreshed 3 minutes ago next pull 06:06

TECH Signal 404

SCM_RIGHTS recvmsg() silently discards file descriptors when ancillary buffer is too small

Linux's SCM_RIGHTS implementation truncates and closes file descriptors that don't fit in the receiver's ancillary buffer, and message-boundary enforcement causes short reads that break edge-triggered I/O assumptions.

WHY IT MATTERS

Engineers passing file descriptors over Unix domain sockets can silently lose descriptors if their recvmsg() ancillary buffer is undersized, with no recovery mechanism. The kernel's artificial message boundaries also mean short reads don't reliably indicate an empty buffer, breaking common edge-triggered I/O patterns.

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

A single SCM_RIGHTS message can carry up to 253 file descriptors, but if recvmsg() lacks sufficient ancillary buffer space, excess descriptors are silently discarded and closed with no way to retrieve them later.

02

recvmsg() artificially limits reads to the byte range of the ancillary message, causing short reads even when more data is buffered, which breaks edge-triggered I/O assumptions that a short read means no more data.

03

Regular read() calls exhibit the same early termination behavior despite being unable to receive ancillary messages, making the root cause of fragmented reads non-obvious during debugging.

THE CLUSTER

Same story, 1 feed.

ORDERED BY FIRST SEEN
github.com via Lobsters SCM_RIGHTS API quirks (2019) Open ↗