Bug 1525641

Summary: Incorrectly relabeled /var/named/chroot/ because of loop
Product: [Fedora] Fedora Reporter: Marek Greško <marek.gresko>
Component: selinux-policy-targetedAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: low    
Version: 30CC: dwalsh, pemensik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-17 01:12:57 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:

Description Marek Greško 2017-12-13 19:13:06 UTC
Description of problem:
when running fixfiles -v -F relabel files in /var/named/chroot are incorrectly relabeled because of loop in /var/named/chroot/var/named/chroot. Policy should be configured to ignore /var/named/chroot/var/named/chroot directory.

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.13.1-283.17.fc27.noarch

How reproducible:


Steps to Reproduce:
1. Run fixfiles -v -F relabel
2. reboot
3. avc denied in logs

Actual results:
Files are incorrectly relabeled.

Expected results:
Files should not be relabeled.

Additional info:

Comment 1 Marek Greško 2018-01-11 10:18:13 UTC
Or should this be bug of fixfiles?

Comment 2 Marek Greško 2018-01-26 20:35:08 UTC
This is the workaround:

# fixfiles -v -F relabel
# cd /var/named/chroot
# restorecon -R -v .

Restorecon will fix the wrongly relabeled files.

Comment 3 Petr Menšík 2018-05-30 13:37:57 UTC
I think named-chroot or named-sdb-chroot service has to be running. Otherwise there would not be /var/named/chroot/var/named/chroot.

Comment 4 Marek Greško 2018-05-30 14:00:31 UTC
Yes, sure. I have named-chroot running.

Comment 5 Marek Greško 2018-11-17 16:44:46 UTC
Something wrong with that?

Comment 6 Petr Menšík 2019-07-10 14:41:37 UTC
There is little I can do about loop I think. bind-chroot package, resp. /usr/libexec/setup-named-chroot.sh script, mount --bind --make-private /var/named to /var/named/chroot/var/named. It has to do it to include all zones in /var/named to chroot. Loop has to be solved somehow in selinux relabel tools. Is there way to mark all files in /var/named/chroot/var/named the same way as /var/named? I am not sure how can I end such loop.

Comment 7 Marek Greško 2019-07-13 15:25:07 UTC
How about setting the /var/named/chroot tree out of labelling? Or should the bug be moved to the tools package?

Comment 8 Lukas Vrabec 2019-07-16 20:26:42 UTC
Hi, 

Could you try this command and then re-run restorecon? 

# semanage fcontext -a -e /var/named /var/named/chroot/var/named

Thanks,
Lukas.

Comment 9 Marek Greško 2019-10-23 21:36:09 UTC
Hi,

first, the restorecon worked correctly before. But I had problem with fixfiles. But after command you recommended the fixfiles is working ok now. Thanks for recommendation. Will this be part of the next version of policy?

Marek

Comment 10 Lukas Vrabec 2019-10-24 14:34:10 UTC
Marek, 

Is path "/var/named/chroot/var/named" part of default configuration for  bind? 

Thanks,
Lukas.

Comment 11 Marek Greško 2019-10-24 16:59:27 UTC
Hi Lukas,

the /var/named/chroot structure is bind mounted when starting default fedora named-chroot service instead of named. It is done by /usr/libexec/setup-named-chroot.sh script.

Marek

Comment 12 Lukas Vrabec 2019-10-25 08:19:42 UTC
Yep, make sense. 

Adding fixes to Fedora:

https://src.fedoraproject.org/rpms/selinux-policy/c/9fb60ef78aac7fed403cf29f49fa37e6a53841f5?branch=master

Comment 13 Marek Greško 2019-10-25 19:40:08 UTC
Hi,

it is strange

# semanage fcontext -a -e /var/named /var/named/chroot/var/named

helped. Because I was observing also mislabeling in /var/named/chroot/dev directory. And potentially others in /var/named/chroot structure.

Marek

Comment 14 Fedora Update System 2019-10-26 17:02:39 UTC
FEDORA-2019-f83217e2bf has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-f83217e2bf

Comment 15 Marek Greško 2019-10-26 17:21:52 UTC
Great. I should probably remove the line:


# semanage fcontext -d -e /var/named /var/named/chroot/var/named

prior to installing update. Am I right?

Thanks

Marek

Comment 16 Fedora Update System 2019-10-27 03:54:37 UTC
selinux-policy-3.14.3-51.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-f83217e2bf

Comment 17 Lukas Vrabec 2019-10-29 09:52:54 UTC
Yes, you could remove it, but it's not necessary. 

Lukas.

Comment 18 Fedora Update System 2019-11-03 14:10:38 UTC
FEDORA-2019-70d80ad4bc has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-70d80ad4bc

Comment 19 Fedora Update System 2019-11-04 02:10:02 UTC
selinux-policy-3.14.3-52.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-70d80ad4bc

Comment 20 Marek Greško 2019-11-05 22:19:33 UTC
Unfortunately, in the meantime I upgraded to Fedora 31. I am no longer able to test F30 packages. The problem is present in Fedora 31.

Comment 21 Lukas Vrabec 2019-11-06 08:44:55 UTC
Hi Marek, 

What is output of:

# rpm -q selinux-policy 

THanks,
Lukas.

Comment 22 Marek Greško 2019-11-06 19:13:01 UTC
selinux-policy-3.14.4-39.fc31.noarch

Comment 23 Marek Greško 2019-11-12 18:03:21 UTC
In selinux-policy-3.14.4-40.fc31.noarch still not working.

Comment 24 Fedora Update System 2019-11-17 01:12:57 UTC
selinux-policy-3.14.3-52.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.