This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2169262 - Security context of swtpm.log of vm with shared tpmstate was not restored after migration failed and shutdown
Summary: Security context of swtpm.log of vm with shared tpmstate was not restored aft...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-13 05:46 UTC by Yanqiu Zhang
Modified: 2023-09-22 17:47 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-22 17:47:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-7522 0 None Migrated None 2023-09-22 17:47:46 UTC
Red Hat Issue Tracker RHELPLAN-148380 0 None None None 2023-02-13 05:46:40 UTC

Description Yanqiu Zhang 2023-02-13 05:46:05 UTC
Description of problem:
For vm with shared tpmstate(/var/lib/libvirt/swtpm), security context of swtpm.log was not restored after migration failed and vm shutdown
Later start vm will meet error:
    'error: Requested operation is not valid: Setting different SELinux label on /var/log/swtpm/libvirt/qemu/vm2-swtpm.log which is already in use'

Version-Release number of selected component (if applicable):
libvirt-9.0.0-4.el9.x86_64
qemu-kvm-7.2.0-8.el9.x86_64
swtpm-0.8.0-1.el9.x86_64
libtpms-0.9.1-2.20211126git1ff6fe1f43.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. mount /var/lib/libvirt/swtpm on a shared storage(on both hosts), e.g. NFS:
# df -hT
10.*.*:/test/swtpm               nfs4       70G   14G   57G  20% /var/lib/libvirt/swtpm
# ls /var/lib/libvirt/swtpm/
(nothing)

2. Define vm with vtpm from an xml
# cat vm2.xml
...
  <cpu mode='host-model' check='partial'>
    <feature policy='disable' name='vmx'/>
  </cpu>
...
    <tpm model='tpm-crb'>
      <backend type='emulator' version='2.0'/>
    </tpm>
...
# virsh define vm2.xml
Domain 'vm2' defined from vm2.xml
# ls /var/lib/libvirt/swtpm/
44db1abb-17eb-4b8e-ac9e-c18549741b65

3. Start vm and check seclabel:
# virsh start vm2
Domain 'vm2' started
# ll -hZ /var/log/swtpm/libvirt/qemu/vm2-swtpm.log
-rw-r--r--. 1 tss tss system_u:object_r:svirt_image_t:s0:c62,c987 19K Feb 12 09:36 /var/log/swtpm/libvirt/qemu/vm2-swtpm.log

4. migrate to a host with different cpu features, to cause failure:
# virsh migrate vm2 --live qemu+ssh://hostB/system --verbose
root@hostB's password:
error: operation failed: guest CPU doesn't match specification: missing features: ds,dtes64,avx512ifma,sha-ni,avx512vbmi,avx512vbmi2,gfni,vaes,vpclmulqdq,avx512bitalg,avx512-vpopcntdq,la57,rdpid,fsrm,wbnoinvd

# ll -hZ /var/log/swtpm/libvirt/qemu/vm2-swtpm.log
-rw-r--r--. 1 tss tss system_u:object_r:svirt_image_t:s0:c62,c987 19K Feb 12 09:36 /var/log/swtpm/libvirt/qemu/vm2-swtpm.log

5. Shutdown vm and check seclabel again:
# virsh shutdown vm2
Domain 'vm2' is being shutdown
# virsh list --all
 Id   Name           State
-------------------------------
 -    avocado-vtpm   shut off
 -    vm2            shut off

# ll -hZ /var/log/swtpm/libvirt/qemu/vm2-swtpm.log
-rw-r--r--. 1 tss tss system_u:object_r:svirt_image_t:s0:c62,c987 20K Feb 12 09:37 /var/log/swtpm/libvirt/qemu/vm2-swtpm.log

6. Try to start vm again:
# virsh start vm2
error: Failed to start domain 'vm2'
error: Requested operation is not valid: Setting different SELinux label on /var/log/swtpm/libvirt/qemu/vm2-swtpm.log which is already in use

# ll -hZ /var/log/swtpm/libvirt/qemu/vm2-swtpm.log
-rw-r--r--. 1 tss tss system_u:object_r:virt_log_t:s0 23K Feb 12 09:38 /var/log/swtpm/libvirt/qemu/vm2-swtpm.log

Actual results:
In step5, swtpm.log seclable wasn't restored. Then later start will encounter error.

Expected results:
selinux context of swtpm.log should be restored to system_u:object_r:virt_log_t:s0, like step6 shows.

Additional info:
1. Not reproduced for local tpmstate(/var/lib/libvirt/swtpm not mounted).
2. The vm must be freshly defined on shared tpmstate, otherwise only starting a vm defined on local tpmstate before can not reproduce this issue.
3. Not all kinds of migration failure can reproduce, e.g. migrate with local disk failure can not.

Comment 2 RHEL Program Management 2023-09-22 17:47:18 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 3 RHEL Program Management 2023-09-22 17:47:45 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.