Skip to content

Conversation

priteau
Copy link
Member

@priteau priteau commented Jul 23, 2024

kk7ds added 4 commits July 23, 2024 17:17
Change-Id: Ic3fa16f55acc38cf6c1a4ac1dce4487225e66d04
Closes-Bug: #2059809
(cherry picked from commit ec9c55c)
(cherry picked from commit 58d933e)
(cherry picked from commit 736328f)
(cherry picked from commit af4d819)
(cherry picked from commit d69d441)
(cherry picked from commit f844c8f)
It has been asserted that we should not be calling qemu-img info
on untrusted files. That means we need to know if they have a
backing_file, data_file or other unsafe configuration *before* we use
qemu-img to probe or convert them.

This grafts glance's format_inspector module into nova/images so we
can use it to check the file early for safety. The expectation is that
this will be moved to oslo.utils (or something) later and thus we will
just delete the file from nova and change our import when that happens.

NOTE: This includes whitespace changes from the glance version of
format_inspector.py because of autopep8 demands.

Conflicts:
  nova/conf/workarounds.py

NOTE(elod.illes): conflict is due to the following patch that is only
present in zed: Iab92124b5776a799c7f90d07281d28fcf191c8fe

Change-Id: Iaefbe41b4c4bf0cf95d8f621653fdf65062aaa59
Closes-Bug: #2059809
(cherry picked from commit 9cdce71)
(cherry picked from commit f07fa55)
(cherry picked from commit 0acf5ee)
(cherry picked from commit 67e5376)
(cherry picked from commit da352ed)
(cherry picked from commit b8a3d56)
There is an additional way we can be fooled into using a qcow2 file
with a data-file, which is uploading it as raw to glance and then
booting an instance from it. Because when we go to create the
ephemeral disk from a cached base image, we've lost the information
about the original source's format, we probe the image's file type
without a strict format specified. If a qcow2 file is listed in
glance as a raw, we won't notice it until it is too late.

This brings over another piece of code (proposed against) glance's
format inspector which provides a safe format detection routine. This
patch uses that to detect the format of and run a safety check on the
base image each time we go to use it to create an ephemeral disk
image from it.

This also detects QED files and always marks them as unsafe as we do
not support that format at all. Since we could be fooled into
downloading one and passing it to qemu-img if we don't recognize it,
we need to detect and reject it as unsafe.

Conflicts:
  nova/tests/unit/virt/libvirt/test_utils.py
  nova/virt/libvirt/utils.py

NOTE(elod.illes): conflicts are due to patch to consolidate image
creation functions (I111cfc8a5eae27b15c6312957255fcf973038ddf) is only
introduced in zed.

Change-Id: I4881c8cbceb30c1ff2d2b859c554e0d02043f1f5
(cherry picked from commit b1b88bf)
(cherry picked from commit 8a0d5f2)
(cherry picked from commit 0269234)
(cherry picked from commit 9e10ac2)
(cherry picked from commit 303c2c9)
(cherry picked from commit e7bdaac)
This restores the vmdk_allowed_types checking in create_image()
that was unintentionally lost by tightening the
qemu-type-matches-glance code in the fetch patch recently. Since we
are still detecting the format of base images without metadata, we
would have treated a vmdk file that claims to be raw as raw in fetch,
but then read it like a vmdk once it was used as a base image for
something else.

Conflicts:
  nova/tests/unit/virt/libvirt/test_utils.py
  nova/virt/libvirt/utils.py

NOTE(elod.illes): conflicts are due to patch to consolidate image
creation functions (I111cfc8a5eae27b15c6312957255fcf973038ddf) is only
introduced in zed.

Change-Id: I07b332a7edb814f6a91661651d9d24bfd6651ae7
Related-Bug: #2059809
(cherry picked from commit 08be7b2)
(cherry picked from commit 11301e7)
(cherry picked from commit 70a435f)
(cherry picked from commit f732f84)
(cherry picked from commit a2acb31)
(cherry picked from commit 3ba8ee1)
@priteau priteau self-assigned this Jul 23, 2024
@priteau priteau requested a review from a team as a code owner July 23, 2024 15:24
@priteau priteau requested a review from markgoddard July 23, 2024 15:24
@markgoddard markgoddard merged commit c730645 into stackhpc/yoga Jul 24, 2024
@markgoddard markgoddard deleted the yoga-reapply-ossa-2024-001 branch July 24, 2024 08:23
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.

4 participants