Skip to content

WSLC: Enforce read-only VirtioFS shares at the device host level#14464

Open
benhillis wants to merge 2 commits intofeature/wsl-for-appsfrom
user/benhill/readonly_virtiofs
Open

WSLC: Enforce read-only VirtioFS shares at the device host level#14464
benhillis wants to merge 2 commits intofeature/wsl-for-appsfrom
user/benhill/readonly_virtiofs

Conversation

@benhillis
Copy link
Member

Pass the 'ro' option to AddGuestDevice when mounting a read-only VirtioFS share, ensuring the device host enforces write protection regardless of guest-side mount operations.

Updated DeviceHost package to 1.1.39-0. Added tests for read-only mount enforcement via remount and unmount+remount.

@benhillis benhillis requested a review from a team as a code owner March 17, 2026 19:44
Copilot AI review requested due to automatic review settings March 17, 2026 19:44
0);

// Verify the folder is still not writeable.
ExpectCommandResult(session.get(), {"/bin/sh", "-c", "echo -n content > /win-path/file.txt"}, 1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this testcase fails without the new devicehost .dll.

Copy link
Contributor

@damanm24 damanm24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens read-only VirtioFS share enforcement in WSLA by passing a read-only option to the DeviceHost-backed virtiofs device, and adds regression tests to ensure guest-side remount attempts cannot bypass host-enforced read-only.

Changes:

  • Pass a read-only (“ro”) option to GuestDeviceManager::AddGuestDevice when creating VirtioFS shares marked read-only.
  • Extend WSLA Windows-mount tests to cover remount and unmount+remount bypass attempts for read-only mounts.
  • Update Microsoft.WSL.DeviceHost NuGet package to 1.1.39-0.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/windows/WSLATests.cpp Adds new tests validating read-only enforcement against guest-side remount/bypass attempts.
src/windows/wslaservice/exe/HcsVirtualMachine.cpp Supplies “ro” device-host option when creating read-only VirtioFS shares.
packages.config Bumps DeviceHost package version to pick up required enforcement behavior.

You can also share your feedback on Copilot code review. Take the survey.

@benhillis benhillis force-pushed the user/benhill/readonly_virtiofs branch from 796dbce to 23f2948 Compare March 18, 2026 18:02
Copilot AI review requested due to automatic review settings March 18, 2026 22:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures read-only VirtioFS Windows folder shares are enforced by the device host (not just guest mount flags), preventing guest-side remounts from re-enabling writes. It updates the DeviceHost dependency and extends the WSLA test suite to validate the enforcement behavior.

Changes:

  • Passes the ro option to GuestDeviceManager::AddGuestDevice when creating read-only VirtioFS shares.
  • Updates Microsoft.WSL.DeviceHost NuGet package to 1.1.39-0.
  • Adds WSLA tests covering read-only enforcement across remount,rw and unmount+remount attempts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/windows/WSLATests.cpp Adds coverage to ensure read-only Windows mounts remain non-writable even after guest remount/remount-bypass attempts.
test/windows/Common.cpp Expands WER dump capture process list to include dllhost.exe during hang reporting.
src/windows/wslaservice/exe/HcsVirtualMachine.cpp Adds ro option propagation to the VirtioFS device-host creation path for read-only shares.
packages.config Bumps Microsoft.WSL.DeviceHost package version to pick up the enforcement behavior.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +838 to +839
L"wslc.exe",
L"dllhost.exe"};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is temporary, I am trying to track down the hang.

Ben Hillis added 2 commits March 19, 2026 07:42
Pass the 'ro' option to AddGuestDevice when mounting a read-only
VirtioFS share, ensuring the device host enforces write protection
regardless of guest-side mount operations.

Updated DeviceHost package to 1.1.39-0. Added tests for read-only
mount enforcement via remount and unmount+remount.
@benhillis benhillis force-pushed the user/benhill/readonly_virtiofs branch from 21d1b61 to fecd474 Compare March 19, 2026 14:42
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.

3 participants