Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-110181

restorecon -i does not ignore files/directories if they are removed while relabeling

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • rhel-10.0
    • policycoreutils
    • No
    • Low
    • 1
    • rhel-security-selinux
    • 2
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • SELINUX 251029: 14
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      This is related to https://issues.redhat.com/browse/RHEL-5172 but the original issue does not mention the "-i" flag. According to the man page:

             -i     ignore files that do not exist. 

      However this only applies during initial file/directory scanning, not while running restorecon. Thus, ENOENT errors can still happen while restorecon runs, returning an error exit code.

      What is the impact of this issue to you?

      When restorecon runs against a directory whose underlying files/directories get deleted while restorecon is running, an error occurs, despite specifying "-i" in the command line.

      Please provide the package NVR for which the bug is seen:

      policycoreutils-3.8-1.el10.x86_64

      How reproducible is this bug?:

      Every time

      Steps to reproduce

      1. On one shell session, run:
        1. mkdir foo; cd foo; while :; do touch a b c; chcon -t etc_t a b c; rm -f a b c; done
      1. On another shell session, while the first 'while' is still running, run:
        1. while true; do restorecon -RFivv foo; done 

      Expected results

      No errors should occur due to ENOENT, as "-i" is used.

      Actual results

      The following error is shown (depending on timing since the test only uses 3 files, but it should get triggered quickly enough nonetheless):

      restorecon: Could not set context for /root/foo/a:  No such file or directory
      restorecon: Could not set context for /root/foo/b:  No such file or directory
      restorecon: Could not set context for /root/foo/c:  No such file or directory 

       

              vmojzis@redhat.com Vit Mojzis
              rhn-support-jsantos Juan Santos
              Vit Mojzis Vit Mojzis
              SSG Security QE SSG Security QE
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: