Skip to content

lxd/device: Disable virtiofsd idmap for shifted volumes - #18709

Open
jonathan-conder wants to merge 1 commit into
canonical:mainfrom
jonathan-conder:shifted-volumes-in-vms
Open

lxd/device: Disable virtiofsd idmap for shifted volumes#18709
jonathan-conder wants to merge 1 commit into
canonical:mainfrom
jonathan-conder:shifted-volumes-in-vms

Conversation

@jonathan-conder

Copy link
Copy Markdown
Contributor

Partially fixes #18686. My rationale is described there.

Without this, file ownership in VMs doesn't match containers. This is technically a breaking change, but I suspect not many people are using raw.idmap together with shifted volumes, otherwise #18561 probably would have been discovered sooner. If it's an issue I'm happy to gate this behind a new config option though.

Checklist

@jonathan-conder
jonathan-conder force-pushed the shifted-volumes-in-vms branch 2 times, most recently from 6abc738 to a226aa9 Compare July 9, 2026 04:04
@tomponline
tomponline requested a review from Copilot July 9, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adjusts VM virtio-fs behavior so virtiofsd does not apply instance raw.idmap when serving shifted storage volumes, aligning file ownership semantics between VMs and containers and addressing the ownership mismatch described in #18686.

Changes:

  • Update VM disk device setup to avoid parsing/applying raw.idmap for security.shifted volumes when starting virtiofsd.
  • Add an integration test ensuring shifted volumes in VMs preserve on-disk ownership (i.e. do not appear as nobody:nogroup) even when raw.idmap is set.

Reviewed changes

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

File Description
lxd/device/disk.go Skips applying raw.idmap to virtiofsd for security.shifted volumes during VM disk setup.
test/suites/vm.sh Adds a regression test validating ownership consistency for shifted volumes shared into VMs over virtio-fs.

Comment thread lxd/device/disk.go
Without this, file ownership in VMs doesn't match containers. This is
technically a breaking change, but I suspect not many people are using
raw.idmap together with shifted volumes, otherwise canonical#18561 probably would
have been discovered sooner. If it's an issue I'm happy to gate this
behind a new config option though.

Signed-off-by: Jonathan Conder <jonathan.conder@canonical.com>
@jonathan-conder
jonathan-conder force-pushed the shifted-volumes-in-vms branch from a226aa9 to 03fd41d Compare July 13, 2026 00:56
@jonathan-conder

Copy link
Copy Markdown
Contributor Author

@tomponline Another approach would be to keep running virtiofsd in a user namespace anyway, but shift the mount that it looks at. e.g. if someone exploits a buffer overflow in virtiofsd itself they would be able to write files as root within the mount, but not to /etc/shadow or w/e.

@tomponline

tomponline commented Jul 13, 2026

Copy link
Copy Markdown
Member

@tomponline Another approach would be to keep running virtiofsd in a user namespace anyway, but shift the mount that it looks at. e.g. if someone exploits a buffer overflow in virtiofsd itself they would be able to write files as root within the mount, but not to /etc/shadow or w/e.

Yes, effectively I think you're proposing to sandbox virtiofsd to give it permission to write/read files as root, but not to be able to run code as root. Right?

@jonathan-conder

Copy link
Copy Markdown
Contributor Author

Yes, effectively I think you're proposing to sandbox virtiofsd to give it permission to write/read files as root, but not to be able to run code as root. Right?

Yeah. It would be limited to reading/writing those files within the shifted mount as well, can't touch /etc/shadow, etc.

That said, virtiofsd is already sandboxed. So the change would be to add shifting to the mount (reducing the level of security but matching how things work for containers)

@tomponline

Copy link
Copy Markdown
Member

Right. Lets focus on getting the behaviours aligned and then work on sandboxing separately once the correct behaviour is established. Thanks

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.

File ownership in storage volumes differs between containers and VMs

3 participants