Bug 1191989

Summary: [HC] selinux denials running glusterd
Product: Red Hat Enterprise Linux 7 Reporter: Sandro Bonazzola <sbonazzo>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact: Bara Ancincova <bancinco>
Priority: high    
Version: 7.1CC: lvrabec, mgrepl, mmalik, plautrba, pvrabec, sbonazzo, ssekidde, ylavi
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: gluster
Fixed In Version: selinux-policy-3.13.1-26.el7 Doc Type: Bug Fix
Doc Text:
SELinux policy for Red Hat Gluster Storage has been added Previously, SELinux policy for Red Hat Gluster Storage (RHGS) components was missing, and Gluster worked correctly only when SELinux was in permissive mode. With this update, SELinux policy rules for the *glusterd* (glusterFS Management Service), *glusterfsd* (NFS sever), *smbd*, *nfsd*, *rpcd*, adn *ctdbd* processes have been updated providing SELinux support for Gluster.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 10:26:09 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:
Bug Depends On:    
Bug Blocks: 996870    
Attachments:
Description Flags
ausearch -m avc -m user_avc -m selinux_err -i -ts today
none
setenforce 0 ; scenario; ausearch -m avc -m user_avc -m selinux_err -i -ts today
none
fresh ausearch output none

Description Sandro Bonazzola 2015-02-12 10:59:34 UTC
time->Thu Feb 12 11:48:17 2015
type=SYSCALL msg=audit(1423738097.736:374): arch=c000003e syscall=59 success=no exit=-13 a0=7f5a7c008c70 a1=7f5a7c008a40 a2=7f5a9b200460 a3=8 items=0 ppid=16529 pid=16632 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="glusterd" exe="/usr/sbin/glusterfsd" subj=system_u:system_r:glusterd_t:s0 key=(null)
type=AVC msg=audit(1423738097.736:374): avc:  denied  { execute } for  pid=16632 comm="glusterd" name="S31ganesha-set.sh" dev="sda1" ino=3311 scontext=system_u:system_r:glusterd_t:s0 tcontext=system_u:object_r:glusterd_var_lib_t:s0 tclass=file
----
time->Thu Feb 12 11:48:18 2015
type=SYSCALL msg=audit(1423738098.047:375): arch=c000003e syscall=59 success=no exit=-13 a0=7f5a7c008c70 a1=7f5a7c008a40 a2=7f5a9b200460 a3=8 items=0 ppid=16529 pid=16639 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="glusterd" exe="/usr/sbin/glusterfsd" subj=system_u:system_r:glusterd_t:s0 key=(null)
type=AVC msg=audit(1423738098.047:375): avc:  denied  { execute } for  pid=16639 comm="glusterd" name="S30samba-set.sh" dev="sda1" ino=3310 scontext=system_u:system_r:glusterd_t:s0 tcontext=system_u:object_r:glusterd_var_lib_t:s0 tclass=file

gluster packages are from upstream repository:

glusterfs-3.6.2-1.el7.x86_64
glusterfs-api-3.6.2-1.el7.x86_64
glusterfs-cli-3.6.2-1.el7.x86_64
glusterfs-fuse-3.6.2-1.el7.x86_64
glusterfs-libs-3.6.2-1.el7.x86_64
glusterfs-rdma-3.6.2-1.el7.x86_64
glusterfs-server-3.6.2-1.el7.x86_64

Comment 1 Milos Malik 2015-02-12 11:10:14 UTC
What is the full path to S31ganesha-set.sh and S30samba-set.sh files? Which package do they come from?

Please provide the selinux-policy-targeted version too.

Comment 2 Milos Malik 2015-02-12 11:12:17 UTC
Are there other SELinux denials on your machine?

# ausearch -m avc -m user_avc -m selinux_err -i -ts today

Comment 4 Sandro Bonazzola 2015-02-12 11:57:16 UTC
Created attachment 990893 [details]
ausearch -m avc -m user_avc -m selinux_err -i -ts today

(In reply to Milos Malik from comment #1)
> What is the full path to S31ganesha-set.sh and S30samba-set.sh files?

# locate S31ganesha-set.sh S30samba-set.sh
/var/lib/glusterd/hooks/1/set/post/S30samba-set.sh
/var/lib/glusterd/hooks/1/set/post/S31ganesha-set.sh


> Which package do they come from?

# rpm -qf \
 /var/lib/glusterd/hooks/1/set/post/S30samba-set.sh \
 /var/lib/glusterd/hooks/1/set/post/S31ganesha-set.sh
glusterfs-server-3.6.2-1.el7.x86_64
glusterfs-server-3.6.2-1.el7.x86_64
 
> Please provide the selinux-policy-targeted version too.

# rpm -qv selinux-policy-targeted
selinux-policy-targeted-3.13.1-23.el7.noarch

(In reply to Milos Malik from comment #2)
> Are there other SELinux denials on your machine?
> 
> # ausearch -m avc -m user_avc -m selinux_err -i -ts today

See the attachment

Comment 5 Milos Malik 2015-02-12 12:41:56 UTC
Could you re-run your scenario in permissive mode and attach those AVCs too?

# setenforce 0
# your scenario
# setenforce 1

Comment 6 Sandro Bonazzola 2015-02-12 15:17:46 UTC
Created attachment 990972 [details]
setenforce 0 ; scenario; ausearch -m avc -m user_avc -m selinux_err -i -ts today

(In reply to Milos Malik from comment #5)
> Could you re-run your scenario in permissive mode and attach those AVCs too?
> 
> # setenforce 0
> # your scenario
> # setenforce 1

See attached output

Comment 8 Miroslav Grepl 2015-04-09 09:47:41 UTC
Could you try to label them as bin_t and re-test it?

#chcon -t bin_t /var/lib/glusterd/hooks/1/set/post/S30samba-set.sh
#chcon -t bin_t /var/lib/glusterd/hooks/1/set/post/S31ganesha-set.sh

Comment 9 Sandro Bonazzola 2015-04-24 12:37:46 UTC
Created attachment 1018453 [details]
fresh ausearch output

Comment 10 Sandro Bonazzola 2015-04-24 12:41:38 UTC
Miroslav, it works better if you set a needinfo on me :-)
I'll try again applying your changes in comment #8.

In the meanwhile, can you take a look at attachment in comment #9 ?
It's a fresh output from ausearch -m avc from today on the same kind of deployment I was trying when I opened this bug.

I'd also suggest this for inclusion in 7.1.z.

Comment 11 Milos Malik 2015-04-24 12:53:56 UTC
Based on AVCs in the last attachment:
 * glusterd wants to access /dev/random
 * glusterd wants to execute various shell scripts under /var/lib/glusterd/hooks
 * dhclient wants to access /run/dhclient-ovirtmgmt.pid file
 * sanlock wants to access a symbolic link somewhere under /run/libvirt/

Comment 12 Sandro Bonazzola 2015-05-05 09:49:08 UTC
(In reply to Miroslav Grepl from comment #8)
> Could you try to label them as bin_t and re-test it?
> 
> #chcon -t bin_t /var/lib/glusterd/hooks/1/set/post/S30samba-set.sh
> #chcon -t bin_t /var/lib/glusterd/hooks/1/set/post/S31ganesha-set.sh

above commands solve the issue reported in comment #0

Do you need another BZ for the denials in comment #9?

Comment 13 Miroslav Grepl 2015-06-10 14:36:08 UTC
$ matchpathcon /var/lib/glusterd/hooks/*/*.sh
/var/lib/glusterd/hooks/*/*.sh	system_u:object_r:bin_t:s0

Comment 17 errata-xmlrpc 2015-11-19 10:26:09 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.

https://rhn.redhat.com/errata/RHBA-2015-2300.html