Skip to content

WIP: fix(fd): /dev/fd spelling gate judges the at-position endpoint (#2316) - #2326

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2316-gate-position
Oct 31, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2316-gate-position

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2316 (the #2276 residual; user directive 2026-10-31: residuals get fixed, not parked).

Defect

The #2276 ENXIO gate (reject_invalid_redirects, PR #2300) judged a /dev/fd/N spelling target against the source fd's ambient endpoint, plus a side scan for an earlier entry binding the fd from a net target. GNU performs one ordered walk — redir.c:237 do_redirections, list loop at redir.c:254 — so the spelling opens the binding the fd carries at that list position: a dup of a socket earlier in the same list makes the target a socket (ENXIO), and a file bind earlier in the list shadows an ambient socket (the spelling opens the file).

Fix (mechanism, no per-shape guards)

src/executor/redirection.rs (+71/−14): a positional endpoint-class overlay opened_socket beside the scan's existing opened overlay. Every entry that binds an fd records the class of what it bound — a net open records socket; a file/text/heredoc bind records non-socket; a dup records its source's class resolved at the dup's own position (new helper scan_endpoint_is_socket), so dup chains compose. The spelling arm judges exactly that at-position endpoint; the ambient table (via the #2276 fd_alias_spelling_open_error) judges only when the list never bound the fd. The old ambient-plus-net-side-scan expression is deleted.

Evidence

  • GNU 5.3.20 oracle, script-file probes (live /dev/tcp server): A dup-bound socket spelling → ENXIO rc=1; B ambient socket rebound to file → file-body rc=0; C dup chain → ENXIO rc=1; D net bind then file rebind → file-body rc=0; E dup-face control → streams hello rc=0. Full table + methodology in the cluster REPORT.md.
  • Pins tests/issue2316_spelling_gate_position_regressions.rs: 8/8 green (scrubbed runner). Mirror ("must not refuse") shapes are pinned on the exec face — see the adjacent-gap note below.
  • Controls green: issue2276_socket_spelling_enxio 7/7, issue2272_fdvar_spawn_delivery_regressions 24/24, issue2281_pending_close_positions 6/6.

Adjacent gap found while probing (NOT this issue; flagged for homing)

On the plain command face, a spelling of an in-list binding is resolved ambient-only by the applier/spawn plan — independent of the gate and of sockets: cat 9<data.txt 0</dev/fd/9 → ENOENT on master and on this branch alike (GNU: file-body). So plain-face shapes B/D still end rc=1 below the gate (B now refuses in the applier with ENXIO, D with ENOENT). That is why the mirror pins run on the exec face, whose applier walks the same list sequentially; the gate inputs are identical. Suggested home: a new issue in the fd/spawn-plan family.

The #2276 ENXIO gate (reject_invalid_redirects) judged a /dev/fd/N
spelling target against the source fd's ambient endpoint, plus a
side scan for an earlier entry binding the fd from a net target.
GNU performs one ordered walk (redir.c:237 do_redirections, list
loop at redir.c:254): the spelling opens the binding the fd
carries at that list position, so a dup of a socket earlier in
the same list makes the target a socket (ENXIO), and a file bind
earlier in the list shadows an ambient socket.

Give the gate scan a positional endpoint-class overlay
(opened_socket) beside its existing opened overlay: every entry
that binds an fd records the class of what it bound — a net open
records socket, a file/text/heredoc bind records non-socket, a
dup records its source's class resolved at the dup's own
position (scan_endpoint_is_socket), so dup chains compose. The
spelling arm now judges exactly that at-position endpoint; the
ambient table judges only when the list never bound the fd.

Pins: tests/issue2316_spelling_gate_position_regressions.rs (8).
GNU 5.3.20 oracle probes for both mirror shapes are recorded in
the cluster report. Controls stay green: issue2276 (7),
issue2272 (24), issue2281 (6).

Refs #2316
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.

1 participant