Skip to content

libutil: Use poll() in FdSource::hasData() to avoid fd_set overflow#15757

Merged
xokdvium merged 1 commit into
NixOS:masterfrom
Mic92:poll
Apr 27, 2026
Merged

libutil: Use poll() in FdSource::hasData() to avoid fd_set overflow#15757
xokdvium merged 1 commit into
NixOS:masterfrom
Mic92:poll

Conversation

@Mic92
Copy link
Copy Markdown
Member

@Mic92 Mic92 commented Apr 27, 2026

FD_SET writes past the stack fd_set when fd >= FD_SETSIZE. hasData() runs before every frame in withFramedSink(), so clients with many open fds would corrupt the stack (or abort under glibc _FORTIFY_SOURCE) during addToStore(). poll() has no such limit; Windows keeps select() since its fd_set is a bounded handle array.

This was only ever called on the client for remote building, so not security relevant.

Motivation

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@Mic92 Mic92 requested a review from edolstra as a code owner April 27, 2026 19:37
Comment thread src/libutil-tests/serialise.cc Outdated
FD_SET writes past the stack fd_set when fd >= FD_SETSIZE. hasData()
runs before every frame in withFramedSink(), so clients with many open
fds would corrupt the stack (or abort under glibc _FORTIFY_SOURCE)
during addToStore(). poll() has no such limit; Windows keeps select()
since its fd_set is a bounded handle array.
@xokdvium xokdvium added this pull request to the merge queue Apr 27, 2026
Merged via the queue into NixOS:master with commit 9ff5b82 Apr 27, 2026
16 checks passed
friedenberg added a commit to amarbel-llc/eng that referenced this pull request May 16, 2026
- clean-nix-fetcher-cache: interactive wipe of tarball-cache-v2/,
  tarball-cache/, gitv3/, and fetcher-cache-v4.sqlite*. Refuses to
  run if any nix processes are alive. Excluded from the aggregate
  `clean` recipe.
- build-nix: split into [linux] (wrapped with prlimit --nofile=1023:1023)
  and [macos] (unchanged) variants to dodge the upstream nix FD_SETSIZE
  crash exposed by 2.34.6's RLIMIT_NOFILE bump (NixOS/nix#15205). The
  select->poll fix (NixOS/nix#15757) is on master only as of 2026-05.
- build-home (linux): wrap the `nix run home-manager` invocation with
  the same prlimit guard.
- debug-nix-env-isolation: probe whether env is the differentiator for
  a `nix build` "missing object" failure that reproduces in one shell
  but not another. Runs the build under current / minimal / from-file
  envs and writes each log to .tmp/debug-nix-env-isolation/<ts>/.

Tracking issue: #79.

:clown: Generated with [Clown](https://github.com/amarbel-llc/clown)
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 this pull request may close these issues.

2 participants