rules for images on attach-device not containing lock permission
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu Cloud Archive |
Fix Released
|
Critical
|
Unassigned | ||
Pike |
Fix Released
|
Critical
|
Unassigned | ||
Queens |
Fix Released
|
Critical
|
Unassigned | ||
libvirt (Ubuntu) |
Fix Released
|
Critical
|
Unassigned | ||
Artful |
Fix Released
|
Critical
|
Unassigned |
Bug Description
[Impact]
* Qemu 2.10 started to lock image files to ensure no data corruption
occurs. Unfurtunately that isn't covered by the apparmor rules we had
for images so far - it need to add "k" permission.
* This was spotted and done in Artful, but the tests for the hot-add of
disks were hidden behind some other known not-too-bad issues. So by
fixing those tests I realized that hot-add of disks is currently broken
in Artful.
[Test Case]
# Get a very minimal Testguest that keeps running to attach something
$ qemu-img create /tmp/A.img 1M
cat <<EOF > testguest.xml
<domain type='kvm'>
<memory unit='KiB'
<vcpu placement=
<os>
</os>
<features>
</features>
<devices>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'/>
</domain>
EOF
$ virsh define testguest.xml
$ virsh start testguest
# Prepare Disk
$ qemu-img create /tmp/F.img 1M
$ cat <<EOF >diskF.xml
<disk type='file'>
<driver name='qemu'/>
<source file='/tmp/F.img'/>
<target dev='sdc'/>
</disk>
EOF
# Then attach:
$ virsh attach-device testguest diskF.xml
* This should work, but fails without the fix as:
error: internal error: unable to execute QEMU command 'device_add':
Property 'scsi-hd.drive' can't find value 'drive-scsi0-0-0-1'
With a related apparmor denial:
apparmor=
* With the fix the file is rwk and works to be attached
[Regression Potential]
* This is only adding apparmor lock permissions to files added after
start. Thereby the only thing that comes to mind is if now things are
locked that were not before, and thereby cause issues. But OTOH no one
but qemu should lock the image files in use - and if someone else does
he now correctly sees qemu holding the lock. Seems safe to me.
[Other Info]
* This is an release/
asap. I already wrote and submitted a fix to upstream, but given that
this can break a lot of use cases we ahve to fix fast and reroll in
case upstream decides to modify.
---
On something like:
$ virsh attach-device <guest> <xml>
The rule rendered is:
"/tmp/B.img" rw,
This is missing the k flag needed on qemu >=2.10.
This applies to block and file definitions:
<disk type='block'>
<driver name='qemu'/>
<source dev='/tmp/B.img'/>
<target dev='sdb'/>
</disk>
<disk type='file'>
<driver name='qemu'/>
<source file='/tmp/F.img'/>
<target dev='sdc'/>
</disk>
Both are rendered correctly as:
"/tmp/F.img" rwk,
If being part of the domain xml instead of being a hot-add.
tags: | added: virt-aa-helper |
Changed in libvirt (Ubuntu): | |
status: | New → Confirmed |
description: | updated |
description: | updated |
Changed in cloud-archive: | |
status: | New → Triaged |
importance: | Undecided → Critical |
tags: | added: qemu-file-locking |
Tests - static: upstream- git/src/ virt-aa- helper --create --dryrun --uuid 'libvirt- f4239a92- f933-4bd3- b9fb-b9c260a7dc 65' < test-virt- aa-helper. xml
sudo ../libvirt-
=> but we know here all works fine
Test - hot-add:
This is more complex - actually it should be added to the overall XML and then passed to virt-aa-helper which would make no difference, but it does.
The call would be from libvirt itself actually with a merged XML IIRC so it should be no difference (other than context being initialized now but not later).
Well debugging will uncover what is going on...