Skip to content

WIP: fix(executor): rubash#1968 - buffered builtin route validates registry-class input redirects - #2051

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/1968-buffered-input-validation
Oct 29, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/1968-buffered-input-validation

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP: #1968 follow-up — the buffered builtin route validates registry-class input redirects before flushing.

Scope note: this cluster originally covered #1963/#1964/#1966/#1968. PR #2015 (fd registry family) landed first and closed #1963, #1964 and #1966; this PR is the narrowed remainder for the one issue still open.

What remains broken on master (measured against GNU bash 5.3.20, loopback listener):

  • echo hi < /dev/tcp/<refused> — GNU suppresses with status 1 and a Connection refused diagnostic; master prints hi, status 0, silent.
  • echo hi <> /dev/tcp/<refused> — same silent execution.
  • echo hi < /dev/tcp/<open> — GNU performs the input netopen (1 connection); master never attempts it (0 connections).

Root cause: the buffered route's ordered walk ignores Input/ReadWrite redirects entirely, and the reject gate's input probes exempt every special-path registry class, so net/synthetic input redirects on echo/printf are never attempted and never settled. (The filed fd-alias shapes were settled by the #1963 gate fix in #2015.)

Change: the flush funnel (write_buffered_builtin_output_ordered) settles the registry classes the gate exempts — Net/SyntheticProc/SyntheticLink via the classified probes — before writing anything. On failure the diagnostic routes through the command's own fd 2, both buffers are discarded, and status 1 joins the builtin's return. Plain/null/fd-alias targets are not re-probed (the gate settled them). GNU: do_redirections precedes the builtin body (execute_cmd.c:5606); failure is redirection_error (redir.c:149-176).

Regression pins: tests/issue1968_builtin_input_redirect_validation_regressions.rs (8 pins: alias/plain/null controls plus refused </<> suppression and exactly-one-connection on the open form, counted by an in-process listener).

Local verification note: lib and pin target compile clean (cargo check); the full test-binary build was OOM-killed twice on the shared dev box (7 GB, many concurrent cluster builds), so the pin run itself is delegated to this PR's CI.

Fixes #1968

…y-class input redirects before flushing

route_builtin_buffered_output's ordered walk ignores Input and
ReadWrite redirects entirely, and the reject gate's input probes
exempt every special-path registry class — so a buffered builtin
(echo/printf) executed and flushed even when its input redirect
was a net target that could not connect: 'echo hi <
/dev/tcp/<refused>' printed hi with status 0, and the open form
never connected at all. (The filed fd-alias shapes were settled
by the #1963 gate fix in #2015; the net/synthetic residue is this
change.) The flush funnel now settles the registry classes the
gate exempts — net and synthetic targets via the classified
probes — before writing: on failure the diagnostic routes through
the command's own fd 2, both buffers are discarded, and status 1
joins the builtin's return. GNU suppresses the command when
do_redirections fails (execute_cmd.c:5606
execute_builtin_or_function rides the same redirect settlement);
a successful net input open connects exactly once and the builtin
runs.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 29, 2026 06:03
@caomengxuan666
caomengxuan666 merged commit 72632ee into master Oct 29, 2026
11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1968-buffered-input-validation branch October 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant