Skip to content

WIP: fix/winx4-rootaudit - #1390

Merged
caomengxuan666 merged 5 commits into
mainfrom
fix/winx4-rootaudit
Oct 26, 2026
Merged

caomengxuan666 merged 5 commits into
mainfrom
fix/winx4-rootaudit

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Fixes #1364

Cluster: winx4-rootaudit — full-command-set audit of bare / resolution (176 commands), under the maintainer's enclave ruling (2026-10-26): bare / = the payload root (WINUXSH_ROOT) uniformly for all internal commands; drive roots are reached only via /c/-style spellings. (This supersedes the issue's original drive-root-alignment expectation.)

Five commands leaked bare / to the current drive root; each now folds operands through the shared native_path operand boundary:

  • mktemp: template directory resolved through the shared operand boundary
  • updatedb: walk roots folded through the shared operand boundary
  • cygpath: shell-namespace spellings converted through the shared operand boundary
  • stat: operand folded before absolutizing in load_file_system_stat
  • locate: -d database path resolved through the shared operand boundary

Verification (winx window successor, 2026-10-26): mingw+Wine probe battery, 16 assertions — 14 PASS / 2 adjudicated (full log: cluster rootaudit-probes.log):

  • All five fixed commands verified in substance: cygpath -w / → payload root, cygpath -w /c → C:\; mktemp -p / created its file inside the payload root (artifact checked on disk); updatedb --localpaths=/ walked the payload root and its database landed payload-side; stat -c %m / reports the operand's volume (Z:-side, from a C: cwd — the cross-volume bug this fix targets), and /c cells return exactly C:\.
  • Shared-route cells pass: ls / lists the payload root, ls /c + ls /c/ reach the drive root, find /, tree /, test -d /, test -e payload marker, cat / is-a-directory error.
  • stat-mount-payload-volume (literal FAIL, substance PASS): output was \\?\Z:\tmp\ instead of a bare Z: — Wine's mount table reports its temp-dir mount with a \\?\ prefix; the operand-volume logic itself is proven by the /c cells and the Z-vs-C cross-volume direction. Expected to read Z:\ under real Windows volume APIs.
  • realpath-slash-payload (FAIL, expectation dispute — realpath is audit class C, not one of the five fixes): realpath / prints /, the shell-namespace canonical spelling, rather than disclosing the host-side payload path like cygpath -w. Recorded as a residual question in the window report; it shows no out-of-enclave resolution.
  • Local probes ran on the pre-rebase tree; the rebase onto current main was conflict-free with zero file overlap (the five fix commits touch only their own command files + unit tests), so the verified code is byte-identical in this PR. locate has no harness vehicle by cluster design; its coverage is the unit tests in this PR (Windows CI).

Residual audit items beyond these five commands are tracked in #1385.

…d boundary (#1364)

Enclave rule (#1364 ruling): a bare "/" names the payload (shell) root
uniformly across the command set. mktemp folded only the drive dialect
in its own normalize_win_shell_path and passed every other spelling to
GetFullPathNameW downstream, so `mktemp -p /` created its file in the
current drive root -- a sandbox leak.

run() now folds the directory side of the template (the -p dir, and the
template's own directory part) through native_path::normalize_api_operand
after the local drive fold, so shell-namespace spellings resolve through
the shell tree exactly like every other command. Drive spellings and
native paths pass through unchanged.

Regression: mktemp_dash_p_bare_slash_uses_shell_root_issue1364 sets
WINUXSH_ROOT to a scratch payload root and asserts the created file
lands inside it.
…1364)

absolute_path() absolutized the walk root with GetFullPathNameW alone,
so `updatedb -d /` (and --localpaths=/ ) walked the current drive root
and stored drive paths in the database instead of walking the payload
(shell) root -- a sandbox leak under the #1364 enclave rule.

The root now passes through native_path::normalize_api_operand before
absolutizing; drive spellings still fold to their drive root inside the
boundary, native and relative roots are unchanged.

Regression: updatedb_bare_slash_walks_shell_root_issue1364 plants a
marker file in a scratch shell root and asserts `updatedb -d /`
records it.
…erand boundary (#1364)

cygpath had no shell-root awareness at all: unix_to_windows merely
replaced separators, so `cygpath -w /` printed "\\" (which every
consumer roots on the current drive) and `-a` absolutized onto the
current drive. Under the #1364 enclave rule the bare "/" names the
payload (shell) root, and cygpath -- the spelling converter -- must
agree with the resolution every other command applies.

unix_to_windows now folds a "/"-initial spelling through
native_path::normalize_api_operand first and adopts the result when it
arrives as a native drive path. Drive spellings fold inside the boundary
to the same drive roots as before (pinned), pseudo-devices and non-shell
spellings pass through untouched, and standalone behaviour without a
configured shell root is unchanged.

Regression: shell_root_bare_slash_converts_to_payload_root_issue1364
asserts `cygpath -w /` prints the configured payload root while
`cygpath -w /c` still prints the C: drive root.
…tat (#1364)

load_file_system_stat ran std::filesystem::absolute on the raw operand
first, rooting a shell spelling ("/") on the current drive, and only
then passed it through the operand boundary -- so with the cwd on a
different drive than the payload root, the filesystem fields (%m mount
point, volume serial, free space) described the cwd's volume instead of
the operand's.

The operand now goes through make_api_path_operand_w first (wide form,
no ANSI-codepage detour) and absolutizing applies to the normalized
spelling; relative operands still join the cwd exactly as before.

No unit test: the divergence is only observable across volumes, which
the single-volume CI cannot stage; it is pinned by this cluster's Wine
probes (payload on Z:, cwd on C:, `stat -c %m /` must report the Z:
volume).
…boundary (#1364)

read_db opened the -d database path with a raw CreateFileW on the
as-typed spelling, so a database spelled from the shell root
(`locate -d /ra.db`) was looked up on the current drive root instead
of the payload (shell) root.

The path now goes through make_api_path_operand and the file is opened
via its extended spelling; relative and native database paths resolve
exactly as before.

Regression: locate_database_path_uses_shell_root_issue1364 plants the
database in a scratch shell root and reads it back via the /ra.db
spelling from a different cwd.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 26, 2026 22:43
@caomengxuan666
caomengxuan666 merged commit beb5655 into main Oct 26, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/winx4-rootaudit branch October 26, 2026 22:43
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.

[bug] ls resolves bare / to the payload root - bypasses the #1274 shared argv boundary (inconsistent with every other tool)

1 participant