-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix private vol handling during updates (QSB #50) #5192
Comments
We could specify a storage API method |
@rustybird Currently,
Oddly enough, if you omit Also, |
I'm not an expert is Qubes OS internals but I think it technically does:
Note: technically whether truncate zero-fills the file contents is platform-dependent. P.S. I think having some way to shrink a volume to 0 size or completely remove it has some advantages:
P.P.S. Could we just make the size of 0 special (ie bypass the test for shrinking)? If the user explicitly asks a volume to be shrunk to 0 size, it's pretty clear they don't care about preserving the data inside. |
That's what I meant by I haven't tested it, but it looks possible to just remove the LVM specific check and change
That safety check and its error message comes from general
Oh right, it probably wouldn't. |
For the case of template reinstall, why not a post-install script that blkdiscards the template private volume if it already exists, lvremoves it then lvcreates it?
Oh yeah. Hmm. I'll just note that a "resize" function for lvm-thin LVs isn't as particularly critical as it is with file-based volumes in general.* That being said, Also, when LVM is in use, Qubes should enforce qubes-created LVs that are multiples of 1MB storage space (to ensure alignment with all possible LVM cluster sizes) and, if partitions are used in the LV, have the partitions start at 1MB and be 1MB aligned. OTOH, the filesystem stuff is generally a nightmare, PLUS we have the Qubes context of avoiding the mounting of VM filesystems or even the parsing of VM LV partitions for security model reasons. If one wants something turnkey in dom0, one would probably need to design a process that utilizes disposable "partition and filesystem adjustment" VMs to compact the filesystems/partitions (or even just to verify they are compacted). Alternately...have the user type "ireallyknowwhatiamdoingpleasedestroymyvolume" every time they shrink a LV from dom0. :) B * Caveat: I do think that the linux templates and template-based AppVMs should be performing fstrim automatically on shutdown (on only the default r/w volumes for that VM), primarily for maximum storage space recovery; the currently utilized discard mount option doesn't recover as much space due to the LVM cluster-size vs. file-system block-size disparity. I look at the LV volume size primarily as a denial-of-service protection against storage resource exhaustion due to bad planning (and possibly attackers). Disposable VMs would not need the fstrim, of course. |
On Admin API level it's already possible - call |
Verify if it really discards old content. QubesOS/qubes-issues#5192
Verify if it really discards old content. QubesOS/qubes-issues#5192
Verify if it really discards old content. QubesOS/qubes-issues#5192
Reinstalling template is a recommended way to get it back to a clean state after potential compromise. In that case it is essential to discard any persistent storage of old template, as it could be used by the attacker to re-compromise it after reinstall. Do this similar as root volume is overridden - via volume import function. Fixes QubesOS/qubes-issues#5192
Add support for importing volume data with qvm-volume tool. This could be also used to clear volume by issuing: qvm-volume import --no-resize some-vm:private /dev/null QubesOS/qubes-issues#5192
Automated announcement from builder-github The package
|
Automated announcement from builder-github The package
|
Automated announcement from builder-github The package
|
Automated announcement from builder-github The package
|
Automated announcement from builder-github The package
Or update dom0 via Qubes Manager. |
Automated announcement from builder-github The package
|
Verify if it really discards old content. QubesOS/qubes-issues#5192 (cherry picked from commit 790c2ad)
Verify if it really discards old content. QubesOS/qubes-issues#5192 (cherry picked from commit 19186f7)
Verify if it really discards old content. QubesOS/qubes-issues#5192 (cherry picked from commit afb0de4)
Qubes OS version
R4.0
Affected component(s) or functionality
dom0 updates i.e.
qubes-dom0-update
Brief summary
The security flaw described in QSB #50 is that a template reinstall process won't erase the contents of the private volume. Assuming the template was compromised before reinstallation, this might result in compromise after reinstallation via contents in /rw.
To Reproduce
qubes-dom0-update --action=reinstall qubes-template-something-os
Expected behavior
Template's *-private volume is blanked-out, causing the template OS to reinitialize it via /usr/lib/qubes/init/setup-rw.sh on the next template startup.
Solutions you've tried
QSB 50 describes a workaround using the more convoluted instructions in the docs (see below).
As for the right way to patch: I don't know of a simple command that can be inserted into
qubes-dom0-update
to achieve a zeroed-out private volume. Theqvm-volume
command doesn't seem to support such a function (and itsresize --force
option appears broken), so the Linux toolsblkdiscard
andtruncate
could be used directly for their respective storage types.A way to determine storage type would be to parse the output of
qvm-volume ls
to get the storage pool for the target volume, then look up the storage type usingqvm-pool -l
. This provides enough information to use the correct zeroing method (i.e. a volume residing in an 'lvm-thin' pool would be zeroed usingblkdiscard
).Another way to resolve the issue would be to add a high-level zeroing function in
qvm-volume
. Unfortunately, the storage API doesn't seem to support either zeroing or independent volume removal or a resize that shrinks (in this case, would be shrink to zero size) – please correct this assertion if its not accurate. Adding a zeroing function to the storage layer, however, could be a reasonable approach.Relevant documentation you've consulted
https://www.qubes-os.org/doc/reinstall-template/#manual-method
Related, non-duplicate issues
The text was updated successfully, but these errors were encountered: