Bug 754646

Summary: SELinux is preventing /usr/sbin/sanlock from search access on NFS directory
Product: Red Hat Enterprise Linux 6 Reporter: Alex Jia <ajia>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: high Docs Contact:
Priority: high    
Version: 6.2CC: berrange, dwalsh, eparis, gsun, mmalik, mzhan, rwu, teigland
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 784586 (view as bug list) Environment:
Last Closed: 2012-06-20 12:29:00 UTC Type: ---
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:    
Bug Blocks: 784586    

Description Alex Jia 2011-11-17 08:45:34 UTC
Description of problem:
Sanlock should be allowed search access on the  directory by default.

Version-Release number of selected component (if applicable):
sanlock-1.8-2.el6
selinux-policy-3.7.19-126.el6
libvirt-lock-sanlock-0.9.4-23.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. following this link:
http://fedoraproject.org/wiki/Features/VirtLockManager  (see 'Dual host testing' section)

2. and enable the following selinux booleans:
virt_use_nfs --> on
virt_use_sanlock --> on

  
Actual results:
"AVC" error in /var/log/audit/audit.log.

Expected results:
allow sanlock search access.

Additional Information:
Source Context                unconfined_u:system_r:sanlock_t:s0-s0:c0.c1023
Target Context                system_u:object_r:nfs_t:s0
Target Objects                 [ dir ]
Source                        sanlock
Source Path                   /usr/sbin/sanlock
Port                          <Unknown>
Host                          localhost.localdomain
Source RPM Packages           sanlock-1.8-2.el6
Target RPM Packages
Policy RPM                    selinux-policy-3.7.19-126.el6
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     localhost.localdomain
Platform                      Linux localhost.localdomain 2.6.32-220.el6.x86_64
                              #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64
Alert Count                   6
First Seen                    Thu 17 Nov 2011 03:16:29 PM CST
Last Seen                     Thu 17 Nov 2011 03:39:34 PM CST
Local ID                      6573384f-1045-476a-9bb6-d024af5182f6

Raw Audit Messages
type=AVC msg=audit(1321515574.664:90425): avc:  denied  { search } for  pid=22546 comm="sanlock" name="" dev=0:1e ino=1703968 scontext=unconfined_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:object_r:nfs_t:s0 tclass=dir


type=AVC msg=audit(1321515574.664:90425): avc:  denied  { open } for  pid=22546 comm="sanlock" name="acd114944f033ea5cbcb8956d389469e" dev=0:1e ino=1705403 scontext=unconfined_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:object_r:nfs_t:s0 tclass=file


type=SYSCALL msg=audit(1321515574.664:90425): arch=x86_64 syscall=open success=yes exit=ENOEXEC a0=7fc0ec000af8 a1=105002 a2=0 a3=0 items=0 ppid=1 pid=22546 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=168 comm=sanlock exe=/usr/sbin/sanlock subj=unconfined_u:system_r:sanlock_t:s0-s0:c0.c1023 key=(null)

Hash: sanlock,sanlock_t,nfs_t,dir,search

audit2allow

#============= sanlock_t ==============
#!!!! This avc is allowed in the current policy

allow sanlock_t nfs_t:dir search;
#!!!! This avc is allowed in the current policy

allow sanlock_t nfs_t:file open;

audit2allow -R

#============= sanlock_t ==============
#!!!! This avc is allowed in the current policy

allow sanlock_t nfs_t:dir search;
#!!!! This avc is allowed in the current policy

allow sanlock_t nfs_t:file open;

Comment 1 Miroslav Grepl 2011-11-17 09:21:54 UTC
We will need to add the same boolean which we have for virtd

sanlock_use_nfs

Comment 2 Miroslav Grepl 2011-11-21 09:30:56 UTC
Added to Fedora.

Comment 10 Milos Malik 2012-04-12 15:15:31 UTC
Hi Dave, could you help us? Why is wdmd calling chown() ? Is it because of /dev/watchdog ?

Comment 11 David Teigland 2012-04-12 15:29:10 UTC
The wdmd daemon is run as "wdmd -G sanlock".
Then socket_gid = group_to_gid("sanlock"), (using getgrnam)
Then it chowns its unix socket to socket_gid so that the
sanlock daemon can connect to it.

http://git.fedorahosted.org/git?p=sanlock.git;a=blob;f=wdmd/main.c;h=18a4109dff5240330748675f2836e537cacdc39d;hb=HEAD#l342

Comment 12 David Teigland 2012-04-12 15:31:14 UTC
The socket is /var/run/wdmd/wdmd.sock

Comment 13 Daniel Walsh 2012-04-13 16:15:41 UTC
Ok I guess we need to allow it.

Comment 16 errata-xmlrpc 2012-06-20 12:29:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0780.html