Repository navigation
[release/11.0] Decode escaped Linux mountinfo paths - #137411
Merged
Merged
Conversation
> [!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: 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. |
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
adamsitnik
approved these changes
Nov 12, 2026
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! |
Member
|
/ba-g unrelated failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
RootandMountPointpaths 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\134040becomes\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 sharedValueStringBuilder.cscompile item to DriveInfo and RuntimeInformation.Tests.Changed files, under
src\libraries\:Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.TryParseMountInfoLine.csCommon\tests\Tests\Interop\procfsTests.csSystem.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csprojSystem.Runtime\tests\System.Runtime.InteropServices.RuntimeInformation.Tests\System.Runtime.InteropServices.RuntimeInformation.Tests.csprojCustomer Impact
#123347 reports incorrect Linux drive information for mounted volumes whose labels contain spaces.
DriveInfo.GetDrives()returns a name such as/run/media/user/DISC\0403instead of/run/media/user/DISC 3.RootDirectoryis incorrect, andDriveTypecan beNoRootDirectoryinstead ofCDRom. A second customer report confirms thatEnvironment.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
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
runtimeKeepalivePopshutdown 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.114and locally built .NET10.0.16binaries. 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..\build.cmd -rc Release -s clr+libs.\build.cmd mono+libs -os browser.\build.cmd mono.corelib+mono.wasmruntime+libs.pretest -os browser.\.dotnet\dotnet.exe build src\libraries\Common\tests\Common.Tests.csproj /t:Test /p:RuntimeConfiguration=Release.\.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.\.dotnet\dotnet.exe build src\libraries\System.IO.FileSystem.DriveInfo\tests\System.IO.FileSystem.DriveInfo.Tests.csproj /t:Test /p:RuntimeConfiguration=Release.\.dotnet\dotnet.exe build src\libraries\System.IO.FileSystem.DriveInfo\src\System.IO.FileSystem.DriveInfo.csproj /p:TargetOS=linux /p:RuntimeConfiguration=Release /p:BuildProjectReferences=falsenet10.0,net10.0-unix, andnet10.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.\.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.exeBrowser execution used the restored, pinned XHarness
net10.0entrypoint throughXHARNESS_CLI_PATHand repository-provisioned V813.9.205. The three RuntimeInformation skips requireRemoteExecutor.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:
release/X.0-staging, notrelease/X.0.release/X.0(no-stagingsuffix).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.