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

semanage fails to get lock if / is on NFS (or /var/lib/selinux/)

    • libsemanage-3.6-3.el9
    • No
    • Important
    • 2
    • rhel-sst-security-selinux
    • ssg_security
    • 20
    • 3
    • QE ack
    • False
    • Hide

      None

      Show
      None
    • None
    • SELINUX 241016 - 241106, SELINUX 241106 - 241127
    • Hide

      The semanage tool is able to lock the transaction file located on NFS.

      Show
      The semanage tool is able to lock the transaction file located on NFS.
    • Pass
    • Needed
    • Automated
    • Release Note Not Required
    • All
    • None

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

      semanage commands with a / on NFSv4

      What is the impact of this issue to you?

      semanage commands unusable

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

      policycoreutils-3.6-2.1.el9.src.rpm

      How reproducible is this bug?:

      always

      Steps to reproduce

      1. Use a NVSv4 mount as root or just /var/lib/selinux/targeted/
      2. 192.168.122.155:/rear/targeted on /var/lib/selinux/targeted type nfs4 (rw,relatime,seclabel,vers=4.2,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.65,loc
        al_lock=none,addr=192.168.122.155)
      1. #  semanage fcontext -a -e /home  /tmp/testdir

      libsemanage.semanage_get_lock: Error obtaining direct transaction lock at /var/lib/selinux/targeted/semanage.trans.LOCK. (Bad file descriptor).
      OSError: Bad file descriptor

      Expected results

      semanage commands usable without error

      Actual results

      semanage fails with lock error.

       

      This is due to this part:

       

       

       

      libsemanage/src/semanage_store.c
      int semanage_install_sandbox(semanage_handle_t * sh)
      ...
             if ((fd = open(lock_file, O_RDONLY)) == -1) { 
                     if ((fd = 
                          open(lock_file, O_RDWR | O_CREAT | O_TRUNC, 
                               S_IRUSR | S_IWUSR)) == -1) { 
                             ERR(sh, "Could not open direct %s at %s.", lock_name, 
                                 lock_file); 
                             return -1; 
                     } 
             }
      

       

      Then flock fails:

                

           if (flock(fd, LOCK_EX | LOCK_NB) == 0) {

      The open must be done with 0_RDWR on a NFSv4 filesystem.

       

       

              rhn-engineering-plautrba Petr Lautrbach
              rhn-support-bwelterl Benoit Welterlen
              Petr Lautrbach Petr Lautrbach
              Milos Malik Milos Malik
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated: