Skip to content

/dev/fd/N 拼写打开 socket 端点应 ENXIO 失败,现宽容 dup 供流 #2276

Closed

Description

@caomengxuan666

现象

经拼写打开 socket 端点的 fd 别名(cat /dev/fd/N、cmd < /dev/fd/N,N 为已连接的 socket,如 /dev/tcp 建立的 fd)时,rubash 宽容地 dup 该描述符并正常供流;GNU bash 5.3.20 则 open 失败、报 ENXIO。

GNU 期望(oracle 实测,fix-2256-devfd-fresh 簇探针)

oracle 构建定义 HAVE_DEV_FD 1,/dev/fd/N 拼写走普通 open(),内核 magic-symlink 语义决定结果:普通文件 fresh open、管道 attach、socket 为 ENXIO(No such device or address),操作数面与重定向面同形。<&N 是独立的 dup2 指令,不在此列、保持共享偏移。

范围与归宿

Regression seed: 已连接 socket fd(listener 配合 /dev/tcp 或 unix socketpair 夹具)+ cat /dev/fd/N 与 cmd < /dev/fd/N 两形,期望 ENXIO 失败;对照组管道 fd 拼写打开仍 attach 成功、普通文件仍 fresh open。

Activity

  1. added this to the 1.5.0 milestone on Oct 30, 2026
  2. added
    bug
    gnu-baseline
    P3-low
    area:fd
    on Oct 30, 2026
  3. caomengxuan666 commented on Oct 31, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by PR #2300 (merged, merge commit d758fd0).

    Opening a socket endpoint through a /dev/fd/N spelling now fails ENXIO at two layers: the alias layer returns the verdict (fd_alias_spelling_open_error), and the do_redirections gate (reject_invalid_redirects) refuses spelling targets whose aliased endpoint is a socket, with the matching decline in the stdin-string spelling arm. GNU ground: the spelling open is a real open of the aliased endpoint, and a socket has no openable path (ENXIO).

    Verification (collector, on the recomposed branch): issue2276 pins 7/7 under a scrubbed fd environment; controls issue2272 24/24, issue2279 13/13, issue2255 14/14, issue2256 25/25; regression 221 + the 6 known local stock reds; lib 985/985; PR CI 11/11 green on the composed head. Known residual (recorded in the fix report, no pin treads it): a spelling whose source was bound earlier in the same list via a dup of a socket is judged against the ambient endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P3-lowarea:fdbuggnu-baseline

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions