Bug 1259018 - restorecon changes many file labels following a clean install
Summary: restorecon changes many file labels following a clean install
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 29
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-01 18:49 UTC by Chris Murphy
Modified: 2023-09-14 03:04 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-27 22:12:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
restorecon F22 cloud atomic (9.06 MB, text/plain)
2015-09-01 20:24 UTC, Chris Murphy
no flags Details
restorecon F23 Workstation (18.53 KB, text/plain)
2015-09-04 01:48 UTC, Chris Murphy
no flags Details

Description Chris Murphy 2015-09-01 18:49:23 UTC
Description of problem: Install Fedora 22 or Fedora 23 (clean). Upon reboot, run restorecon -r -v / and find that many files have labels fixed.


Version-Release number of selected component (if applicable):
All since time immemorial?


How reproducible:
Always


Steps to Reproduce:
1. Clean install Fedora 22 or Fedora 23.
2. Reboot and run restorecon -r -v /

Actual results:

Many files have labels reset, example (incomplete) list:

restorecon reset
/usr/lib/modules/4.2.0-0.rc8.git0.1.fc23.i686/modules.symbols context
system_u:object_r:modules_object_t:s0->system_u:object_r:modules_dep_t:s0

restorecon reset /boot/System.map-4.2.0-0.rc8.git0.1.fc23.i686 context
system_u:object_r:modules_object_t:s0->system_u:object_r:system_map_t:s0

restorecon reset /boot/vmlinuz-4.2.0-0.rc8.git0.1.fc23.i686 context
system_u:object_r:modules_object_t:s0->system_u:object_r:boot_t:s0

restorecon reset /var/lib/os-prober/labels context
unconfined_u:object_r:user_tmp_t:s0->unconfined_u:object_r:bootloader_var_lib_t:s0

restorecon reset /var/log/dnf.log context
system_u:object_r:rpm_log_t:s0->system_u:object_r:var_log_t:s0

restorecon reset
/var/cache/dnf/updates-testing-200adbd074da487f/repodata/repomd.xml
context system_u:object_r:rpm_tmp_t:s0->system_u:object_r:rpm_var_cache_t:s0



Expected results:

I expect the installation should have correct labeling.

Additional info:

Comment 1 Ed Greshko 2015-09-01 20:06:01 UTC
This may or may not be relevant.  However, after if after running restorecon you run "depmond" you will find that several files in /lib/modules/`uname -r` will have their contexts changed back to where they will be flagged as needed to be restored the next time restorecon is run.

Comment 2 Ed Greshko 2015-09-01 20:11:33 UTC
Sorry, that should have read "depmod" in the above comment.

Comment 3 Chris Murphy 2015-09-01 20:24:17 UTC
Created attachment 1069146 [details]
restorecon F22 cloud atomic

Fedora-Cloud_Atomic-x86_64 22.96 tree (current as of last week). Of course much of the filesystem is read only by design, so restorecon can't fix these things, and there's a metric fton of labels that restorecon wants to reset.

Comment 4 Daniel Walsh 2015-09-02 11:19:24 UTC
We need an equivalence label between 

/sysroot/ostree/deploy/fedora-atomic and /

semanage fcontext -a -e / /sysroot/ostree/deploy/fedora-atomic

Would fix the problem.  But we should put this in base policy.

It would be better if this was not OS Specific.

Comment 5 Daniel Walsh 2015-09-02 11:27:50 UTC
For OSTree we might want to exclude  /sysroot/ostree/repo/objects alltogether.  Since these are hard links, and we do not want to relabel them

Comment 6 Chris Murphy 2015-09-04 01:48:06 UTC
Created attachment 1070156 [details]
restorecon F23 Workstation

Fedora-Live-Workstation-x86_64-23_Beta-TC1.iso

Comment 7 Daniel Walsh 2015-09-08 11:39:42 UTC
restorecon reset
/usr/lib/modules/4.2.0-0.rc8.git0.1.fc23.i686/modules.symbols context
system_u:object_r:modules_object_t:s0->system_u:object_r:modules_dep_t:s0

restorecon reset /boot/System.map-4.2.0-0.rc8.git0.1.fc23.i686 context
system_u:object_r:modules_object_t:s0->system_u:object_r:system_map_t:s0


Is there any value in having these be different labeles.  What is the security difference between modules_object_t, system_map_t and modules_dep_t.  If there is nothing we are confining different, we should make them all the same.  I don't think anything is allwoed to write to it.


restorecon reset /boot/vmlinuz-4.2.0-0.rc8.git0.1.fc23.i686 context
system_u:object_r:modules_object_t:s0->system_u:object_r:boot_t:s0

Probably just leaving it labeled modules_object_t would be fine.  Looks like these are mv'd here from a subdir of /lib.  If we changed the mv command that builds the vmlinux-* to use -Z it would probably fix the problem.  And they could be labeled boot_t.  I don't believe this mislabel would cause any problems.

restorecon reset /var/lib/os-prober/labels context
unconfined_u:object_r:user_tmp_t:s0->unconfined_u:object_r:bootloader_var_lib_t:s0

restorecon reset /var/log/dnf.log context
system_u:object_r:rpm_log_t:s0->system_u:object_r:var_log_t:s0

restorecon reset
/var/cache/dnf/updates-testing-200adbd074da487f/repodata/repomd.xml
context system_u:object_r:rpm_tmp_t:s0->system_u:object_r:rpm_var_cache_t:s0




Thee all look like mv issues.

Comment 8 Chris Murphy 2015-09-08 16:29:11 UTC
(In reply to Daniel Walsh from comment #7)
> Thee all look like mv issues.

The anaconda program.log doesn't show mv being used at all during installation. Instead it shows rsync -pogAXtlHrDx. Workstation is a live installation so it uses rsync.

I originally found this on a Server netinstall which also isn't using mv as far as I can tell, it's using dnf/rpm.

Comment 9 Miroslav Grepl 2015-09-10 16:04:53 UTC
Ok we have more bugs here.

> We need an equivalence label between 
> 
> /sysroot/ostree/deploy/fedora-atomic and /
> 
> semanage fcontext -a -e / /sysroot/ostree/deploy/fedora-atomic
> 
> Would fix the problem.  But we should put this in base policy.
> 
> It would be better if this was not OS Specific.

I see we have

policy/modules/kernel/files.if:	files_root_filetrans($1, usr_t, dir, "ostree")
policy/modules/kernel/files.fc:/etc/ostree/remotes.d(/.*)?                      gen_context(system_u:object_r:system_conf_t,s0)
policy/modules/kernel/files.fc:/ostree/repo(/.*)?                      gen_context(system_u:object_r:system_conf_t,s0)
policy/modules/kernel/files.fc:/ostree/deploy/rhel-atomic-host/deploy(/.*)?                      gen_context(system_u:object_r:system_conf_t,s0)
policy/modules/kernel/files.fc:/ostree(/.*)?           gen_context(system_u:object_r:usr_t,s0

Comment 10 Fedora Admin XMLRPC Client 2016-09-27 15:01:39 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 11 Fedora End Of Life 2016-11-24 12:25:56 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 12 Fedora End Of Life 2016-12-20 14:32:41 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 13 Colin Walters 2017-03-31 14:18:52 UTC
I think basically we need:

/sysroot <<none>>
/ostree <<none>>

in policy.

Comment 14 Daniel Walsh 2017-04-04 08:28:49 UTC
Need to open a pull request against 
https://github.com/fedora-selinux/selinux-policy

Comment 15 Fedora End Of Life 2018-05-03 08:05:18 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 16 Fedora End Of Life 2018-05-29 11:49:01 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 17 Colin Walters 2018-12-07 17:39:31 UTC
`restorecon -Rv /` (as is sometimes suggested by SELinux developers, see e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1631033) still totally breaks ostree-based systems.

In the end we'll likely solve this with https://github.com/ostreedev/ostree/issues/1265 though.

Comment 18 Ben Cotton 2019-10-31 19:31:39 UTC
This message is a reminder that Fedora 29 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 29 on 2019-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '29'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 29 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 19 Ben Cotton 2019-11-27 22:12:21 UTC
Fedora 29 changed to end-of-life (EOL) status on 2019-11-26. Fedora 29 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 20 Andrey 2020-04-20 20:39:47 UTC
(In reply to Colin Walters from comment #17)
> `restorecon -Rv /` (as is sometimes suggested by SELinux developers, see
> e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1631033) still totally
> breaks ostree-based systems.
> 
> In the end we'll likely solve this with
> https://github.com/ostreedev/ostree/issues/1265 though.

People keep stumble upon it, let's do something please!
Now I broke my work Fedora Silverblue system with that restorecon, and I'm not the only one:
https://discussion.fedoraproject.org/t/i-cant-boot-into-either-my-latest-or-previous-ostree-after-running-restorecon/
(I can’t boot into either my latest or previous ostree after running restorecon)

Comment 21 Andrey 2020-04-21 11:30:41 UTC
(In reply to Colin Walters from comment #17)
> In the end we'll likely solve this with
> https://github.com/ostreedev/ostree/issues/1265 though.

The git issue is closed but the bug is still reproducible. Why is that?

Comment 22 Red Hat Bugzilla 2023-09-14 03:04:38 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days


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