Bug 2093956
Summary: | 'swtpm' binary is denied write/"append" permissions to log files under /var/log/swtpm/ | ||
---|---|---|---|
Product: | Red Hat OpenStack | Reporter: | Kashyap Chamarthy <kchamart> |
Component: | openstack-tripleo-heat-templates | Assignee: | OSP Team <rhos-maint> |
Status: | CLOSED WONTFIX | QA Contact: | Joe H. Rahme <jhakimra> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | unspecified | CC: | bdobreli, berrange, cjeanner, dwalsh, jnovy, jpichon, lvrabec, mburns, mmalik, phou, tsweeney, zpytela |
Target Milestone: | rc | Keywords: | Triaged |
Target Release: | --- | Flags: | bdobreli:
needinfo-
|
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | No Doc Update | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2024-04-19 14:52:25 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 2138102 | ||
Bug Blocks: | 1782128 |
Description
Kashyap Chamarthy
2022-06-06 12:56:26 UTC
Hm, afaik, containers will always expose container_ro_file_t inside the container itself. Here, it looks more like svirt_t isn't allowed to write on the container_ro_file_t type, which kind of makes sense. Since it's more than probably restricted to our (weird?) OSP usage, we may just add the required policy in openstack-selinux[1]. Cheers, C. [1] https://github.com/redhat-openstack/openstack-selinux/blob/master/os-virt.te I don't think we should allow svirt_t to write on the container_ro_file_t. We need to follow the described above qemu binary vs logs example instead. For logs having container_ro_file_t is an obvious mistake @dwalsh: Hi, Dan — any opinions here? I agree with cjeanner that this is likely to be specific to the way OSP is deployed, and I also agree with bogdando that we don't want to allow writing to container_ro_file_t. Looking into THT, it looks like the container_file_t type for /var/log/libvirt/qemu/ is defined here: https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L940 Meanwhile, while I see a container_file_t type for /var/log/containers/libvirt/swtpm at https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L941, the logs seem to actually exist elsewhere based on the description for this bug, as it mentions /var/log/swtpm/libvirt/ instead. I'm not familiar enough with THT or swtpm to be sure, or confirm if this needs a new definition or if the existing log definition in THT is a typo, but my hunch is that this should be resolved in the tripleo-heat-templates component. In tripleo we use /var/log/containers/<element> for the containerized element logging. We cannot change that as containerized logrotate also depends on that. Could you please clarify what should be changed in t-h-t, /var/log/containers/libvirt/swtpm path to /var/log/swtpm/libvirt/:/var/log/swtpm/libvirt on the host? Unfortunately we cannot do that I'm wondering if adding something like "{ 'path': /var/log/swtpm/, 'setype': container_file_t, 'mode': '0750' }" after L941 would help, since that seems to be the path we want to change the type of? (Or with /var/log/swtpm/libvirt/qemu, maybe) From what I can tell, for the qemu logs we have this to mount the volume: https://github.com/openstack/tripleo-heat-templates/blob/321e740d/deployment/logging/files/nova-libvirt.yaml#L156 - /var/log/containers/libvirt:/var/log/libvirt:shared,z # +qemu subdir and this to set the type: https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L940 - { 'path': /var/log/libvirt/qemu, 'setype': container_file_t } (Note: Not "/var/log/containers") While the swtpm mount and logs look like this: https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L681 - /var/log/containers/libvirt/swtpm:/var/log/swtpm:z https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L941 - { 'path': /var/log/containers/libvirt/swtpm, 'setype': container_file_t, 'mode': '0750' } I'm seeing now that this says "puppet" in the filename so I'm not sure if that's the file actually used, but even if this is the wrong place, it seems to me like this is something that could be resolved at deployment time in OSP in the same way it's done for the other qemu logs, by setting the type explicitly in THT? > I'm wondering if adding something like "{ 'path': /var/log/swtpm/, 'setype': container_file_t, 'mode': '0750' }" after L941 would help, since that seems to be the path we want to change the type of? (Or with /var/log/swtpm/libvirt/qemu, maybe) That would create a host path, which we cannot use as the container bind-mount (see the /var/log/containers/<element> logging architecture explained). So that would not fix the issue. > From what I can tell, for the qemu logs we have this to mount the volume: ? https://github.com/openstack/tripleo-heat-templates/blob/321e740d/deployment/logging/files/nova-libvirt.yaml#L156 > - /var/log/containers/libvirt:/var/log/libvirt:shared,z # +qemu subdir yes, this also covers /var/log/containers/libvirt/{qemu,swtpm} inside of container. > and this to set the type: > https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L940 > - { 'path': /var/log/libvirt/qemu, 'setype': container_file_t } > (Note: Not "/var/log/containers") That should be a leftover, we can remove this, it is no longer used. > While the swtpm mount and logs look like this: > https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L681 > - /var/log/containers/libvirt/swtpm:/var/log/swtpm:z > https://github.com/openstack/tripleo-heat-templates/blob/321e740/deployment/nova/nova-modular-libvirt-container-puppet.yaml#L941 > - { 'path': /var/log/containers/libvirt/swtpm, 'setype': container_file_t, 'mode': '0750' } Yes, it follows the same approach that other containerized services logging takes. We cannot change that. SELinux does not complain for those, we should do the same to swtpm logs in /var/log/containers/libvirt This is svirt policy not container-selinux. Hi berrange, can you please look at this bz? (In reply to Nikola Knazekova from comment #10) > Hi berrange, > > can you please look at this bz? I'm not sure what you're asking me to say ? The problem looks pretty clearly understood in that the /var/log/swtpm location inside the container is labelled incorrectly with container_ro_file_t, rather than container_file_t OSP deployment tools needs to decide how to configure the container and any passthrough bind mounts, such that the /var/log/swtpm location is writable. I think this bug should be re-assigned to some component under OSP, not selinux-policy, but I don't know what OSP tool is relevant. Kashyap can help ..... In which rhel version can we have that container_logwriter_t, so that we can use it in OSP as well? The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days |