Skip to content

[release/11.0] Decode escaped Linux mountinfo paths - #137411

Merged
krwq merged 1 commit into
release/11.0from
backport/pr-137195-to-release/11.0
Nov 17, 2026
Merged

krwq merged 1 commit into
release/11.0from
backport/pr-137195-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Note

This pull request description was updated with AI (GitHub Copilot).

Backport of #137195 to release/11.0

/cc @krwq

Fixes Issue #123347

main PR #137195

Description

Decode escaped Root and MountPoint paths when parsing Linux /proc/self/mountinfo. Keep ordinary paths as spans into the input, decode the four supported escapes in one pass, and preserve unknown or truncated sequences. A literal \134040 becomes \040, not a space. Filesystem-type and super-options fields remain unchanged.

This is the automatic .NET 11 backport of #137195 (e0bc8a0abf07459a1b5b993896e6478c65166106). The decoder and regression-test files are byte-for-byte identical to the merged main fix. Unlike the .NET 10 backport in #137420, this backport did not require a manual project-file conflict resolution. The project changes add the shared ValueStringBuilder.cs compile item to DriveInfo and RuntimeInformation.Tests.

Changed files, under src\libraries\:

  • Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.TryParseMountInfoLine.cs
  • Common\tests\Tests\Interop\procfsTests.cs
  • System.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csproj
  • System.Runtime\tests\System.Runtime.InteropServices.RuntimeInformation.Tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj

Customer Impact

  • Customer reported
  • Found internally

#123347 reports incorrect Linux drive information for mounted volumes whose labels contain spaces. DriveInfo.GetDrives() returns a name such as /run/media/user/DISC\0403 instead of /run/media/user/DISC 3. RootDirectory is incorrect, and DriveType can be NoRootDirectory instead of CDRom. A second customer report confirms that Environment.GetLogicalDrives() is also affected.

Without this fix, applications cannot reliably use those returned paths. The shared parser also supplies filesystem-type lookup and cgroup paths. The change handles the Linux mount-table escapes for spaces, tabs, newlines, and backslashes.

Regression

  • Yes
  • No

Introduced in .NET 10 by #116102, which switched Linux mount-point enumeration and filesystem-type lookup to /proc/self/mountinfo, and carried forward into .NET 11. The customer reports that the same code worked on .NET 8 and .NET 9.

Testing

The added tests cover both pathname fields, all four supported escapes, combined and literal escapes, unknown/truncated sequences, Unicode, stack/pool buffer boundaries, and preservation of input-backed spans for ordinary paths. There are 31 mountinfo parser cases: the expanded 24-case theory, six buffer-boundary cases, and the original-input-span check. The previous parser coverage did not exercise the escaped pathname cases.

Validation scope: No separate local .NET 11 build or test run was performed for this description update. The results below are supporting evidence from the manual .NET 10 backport in #137420, not .NET 11 test results. Validation of the original main fix is recorded in #137195. The .NET 11 decoder and regression-test file blobs were compared with main and match exactly.

On the .NET 10 worktree, the original parser reproduced 18 expected failures among the 24 theory cases, with no skips or runner errors. The fixed code passed all 31 parser cases on Windows and browser. Windows also passed 1,701 Common tests, 13 existing cgroup mount/path cases, 15 RuntimeInformation tests, and 24 DriveInfo tests. The Linux-managed DriveInfo build passed all three target frameworks. Browser Common passed 1,124 tests; browser RuntimeInformation passed 9 tests with 3 existing remote-executor skips.

Pre-existing .NET 10 browser limitation: the browser commands returned 0 and wrote successful test results, but the Debug WASM runner then logged a runtimeKeepalivePop shutdown assertion and "Application exited without sending a wasm exit message." This was also reproduced with the exact original release/10.0 CoreLib parser and original Common test source: 1,098 tests passed, with the same shutdown diagnostics and exit code 0. No WASM runtime or runner changes are included in this fix. This observation is not a claim about a .NET 11 browser run.

No live Linux mount smoke test or WASI runtime test was run locally. No shared mount state was changed.

Supporting .NET 10 build/test commands and results

These are the existing results from #137420, using SDK 10.0.114 and locally built .NET 10.0.16 binaries. Windows uses Release CoreCLR and Debug libraries/tests; browser uses Debug Mono. Cross-target builds were run serially. %CD% represents that .NET 10 worktree root; these commands were not rerun against release/11.0 for this description update.

Command Result on the .NET 10 backport
.\build.cmd -rc Release -s clr+libs Passed before changes and after the port; 0 MSBuild warnings/errors.
.\build.cmd mono+libs -os browser Passed before changes; 0 MSBuild warnings/errors.
.\build.cmd mono.corelib+mono.wasmruntime+libs.pretest -os browser Passed after the port and again after restoring the fixed product from the baseline comparison; 0 MSBuild warnings/errors.
.\.dotnet\dotnet.exe build src\libraries\Common\tests\Common.Tests.csproj /t:Test /p:RuntimeConfiguration=Release Passed: 1,701 tests, 0 failures/skips/runner errors.
.\.dotnet\dotnet.exe build src\libraries\System.Runtime\tests\System.Runtime.InteropServices.RuntimeInformation.Tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj /t:Test /p:RuntimeConfiguration=Release Passed: 15 tests, 0 failures/skips/runner errors.
.\.dotnet\dotnet.exe build src\libraries\System.IO.FileSystem.DriveInfo\tests\System.IO.FileSystem.DriveInfo.Tests.csproj /t:Test /p:RuntimeConfiguration=Release Passed: 24 tests, 0 failures/skips/runner errors.
.\.dotnet\dotnet.exe build src\libraries\System.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csproj /p:TargetOS=linux /p:RuntimeConfiguration=Release /p:BuildProjectReferences=false Passed: net10.0, net10.0-unix, and net10.0-windows; 0 warnings/errors.
.\.dotnet\dotnet.exe build src\libraries\Common\tests\Common.Tests.csproj /t:Test /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=Mono /p:InstallV8ForTests=true /p:WasmXHarnessArgsCli=--js-engine-path=%CD%\artifacts\bin\v8-13.9.205\d8.exe 1,124 passed, 0 failures/skips/runner XML errors; command exit 0. Pre-existing shutdown limitation described above.
.\.dotnet\dotnet.exe build src\libraries\System.Runtime\tests\System.Runtime.InteropServices.RuntimeInformation.Tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj /t:Test /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=Mono /p:InstallV8ForTests=true /p:WasmXHarnessArgsCli=--js-engine-path=%CD%\artifacts\bin\v8-13.9.205\d8.exe 9 passed, 3 existing remote-executor skips, 0 failures/runner XML errors; command exit 0. Same pre-existing shutdown limitation.

Browser execution used the restored, pinned XHarness net10.0 entrypoint through XHARNESS_CLI_PATH and repository-provisioned V8 13.9.205. The three RuntimeInformation skips require RemoteExecutor.IsSupported; no tests were changed to skip.

The 13 cgroup cases were source-linked into the RuntimeInformation harness using ignored scratch compile-item overrides. The negative control and browser baseline comparison also used exact original source snapshots through scratch overrides. Final product and normal test projects were rebuilt without those overrides. Full setup, exact supplemental control commands, baseline comparison, and results are recorded in #137420.

Risk

Low. This is the already-merged managed fix, with no decoder changes for the .NET 11 backport, no new public APIs, and no native-code changes. Only the two pathname fields are decoded, and only when they contain a backslash. Ordinary paths retain their input-backed spans. Filesystem-type and super-options fields remain unchanged; unknown/truncated sequences and literal escaped backslashes are covered by regression tests.

The two project changes only include the existing shared builder source. There is no .NET 10-specific conflict resolution in this PR. Supporting validation covers the shared decoder, cgroup callers, affected project files, Linux-managed compilation, and browser compilation/execution on .NET 10; it is not presented as separate .NET 11 execution evidence.

IMPORTANT: If this backport is for a servicing release, please verify that:

  • For .NET 8 and .NET 9: The PR target branch is release/X.0-staging, not release/X.0.
  • For .NET 10+: The PR target branch is release/X.0 (no -staging suffix).

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

AI-generated with GitHub Copilot.

> [!NOTE]
> This pull request was generated with AI (GitHub Copilot).

<!-- -->

Fixes #123347.

## Summary

Decode escaped `Root` and `MountPoint` paths when parsing Linux
`/proc/self/mountinfo`. This fixes `DriveInfo.GetDrives()` and
`Environment.GetLogicalDrives()` returning paths such as
`/run/media/user/DISC\0403` instead of `/run/media/user/DISC 3`. The
shared parser also supplies filesystem-type lookup and cgroup path
construction.

The [Linux getmntent(3)
documentation](https://man7.org/linux/man-pages/man3/getmntent.3.html#DESCRIPTION)
describes the mount-table escaping convention:

> ... octal escapes are used to represent the characters space (`\040`),
tab (`\011`), newline (`\012`), and backslash (`\\`) ...
>
> When converting from escaped representation, the sequence `\134` is
also converted to a backslash.

Use the existing `ValueStringBuilder` pattern to decode these escapes in
one pass. Unescaped paths retain spans into the input without
allocating. Decode only the original input, so `\134040` becomes literal
`\040`, not a space. Leave filesystem-type and super-options fields
unchanged.

Extend the parser tests for both path fields, combined and literal
escapes, unknown/truncated sequences, Unicode, stack/pool buffer
boundaries, and the unchanged zero-copy path. No new public API or
platform support is added.

## Validation

Run on Windows with the local .NET 12 build:

| Command | Result |
| --- | --- |
| `.\build.cmd -rc Release -s clr+libs` | Passed, 0 warnings/errors. Run
before the final debug-only entry assertion; the targeted commands below
passed again after that assertion was added. |
| `.\.dotnet\dotnet.exe build
src\libraries\Common\tests\Common.Tests.csproj /t:Test
/p:RuntimeConfiguration=Release` | Passed: 1,757 tests, 0
failures/skips. |
| `.\.dotnet\dotnet.exe build
src\libraries\System.Runtime\tests\System.Runtime.InteropServices.RuntimeInformation.Tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csproj
/t:Test /p:RuntimeConfiguration=Release` | Passed: 15 tests, 0
failures/skips. |
| `.\.dotnet\dotnet.exe build
src\libraries\System.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csproj
/p:TargetOS=linux /p:RuntimeConfiguration=Release
/p:BuildProjectReferences=false` | Passed: all three managed targets,
including `net12.0-unix`. |

The expanded parser theory was also run against the original
implementation: 18 of 24 cases failed as expected, with no runner
errors. All 24 cases, six buffer-boundary cases, and the original-span
check pass with the fix.

A source-linked BenchmarkDotNet check on the built .NET 12 runtime
measured 0 B for ordinary paths, 72 B for one space-escaped path, and 96
B when both paths contained combined escapes. Large paths use pooled
storage; a cold pool can allocate a buffer.

The Linux bind-mount smoke test was not run: this Windows host has no
usable WSL installation.

Resolves #123347

> AI-generated with GitHub Copilot.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@krwq
krwq requested a review from adamsitnik November 12, 2026 12:40
@ViveliDuCh

Copy link
Copy Markdown
Member

Hi,

the code complete date for 11.0.1 (the December 2026 release) is Monday 16 November. Make sure to merge this PR on that date at the latest, or it won't make it into that release.

As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval).

Happy to help with the merge if needed!

@krwq krwq added the Servicing-approved Approved for servicing release label Nov 17, 2026
@krwq

krwq commented Nov 17, 2026

Copy link
Copy Markdown
Member

/ba-g unrelated failures

@krwq
krwq merged commit 9f349af into release/11.0 Nov 17, 2026
89 of 94 checks passed
@krwq
krwq deleted the backport/pr-137195-to-release/11.0 branch November 17, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants