Bug 620576

Summary: luci generates selinux avcs
Product: Red Hat Enterprise Linux 6 Reporter: Chris Feist <cfeist>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: Cluster QE <mspqa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: borgan, cfeist, cluster-maint, eparis, jha, jmorris, mgrepl, mmalik, sdake, sdsmall, slevine, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.7.19-36.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 619893 Environment:
Last Closed: 2010-11-15 14:48:18 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: 619893    
Bug Blocks: 616643, 619918    
Attachments:
Description Flags
Ricci policy that seems to fix the issue. none

Comment 1 Chris Feist 2010-08-02 21:47:56 UTC
Created attachment 436138 [details]
Ricci policy that seems to fix the issue.

Ricci policy that seems to fix the issue.

Comment 2 Chris Feist 2010-08-02 21:49:14 UTC
We need to wait until 619893 is fixed to verify that this is a blocker that needs to be fixed by 6.0, but right now it appears that this will cause issues with luci/ricci in RHEL 6.0 when selinux is in targeted.

Comment 4 Daniel Walsh 2010-08-03 13:21:33 UTC
Chris the policy you attached is not very good.  

We can add

kernel_request_load_module(ricci_modclusterd_t)


type ricci_modclusterd_tmpfs_t;
files_tmpfs_file(ricci_modclusterd_tmpfs_t)

manage_dirs_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, ricci_modclusterd_tmpfs_t)
manage_files_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, ricci_modclusterd_tmpfs_t)
fs_tmpfs_filetrans(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, { dir file })


But we also need to know which tcp port modcluserd needs to connect to.

Comment 5 Chris Feist 2010-08-03 14:37:22 UTC
I just used the output from audit2allow to generate the old policy.  modclusterd is a server listening on port 16851, I believe it is only a server, I don't think it makes tcp connections elsewhere.  (I will check into this).

Comment 6 Daniel Walsh 2010-08-03 15:35:38 UTC
type=1400 audit(1280503340.368:54): avc:  denied  { name_connect } for 
pid=1876 comm="modclusterd" scontext=system_u:system_r:ricci_modclusterd_t:s0
tcontext=system_u:object_r:port_t:s0 tclass=tcp_socket

This avc says that is it trying to connect somewhere.  The problem is you did not include the full AVC report to see which port it is tryint to connect to.

Comment 7 Chris Feist 2010-08-03 18:47:33 UTC
type=AVC msg=audit(1280782866.051:70): avc:  denied  { name_connect } for  pid=3507 comm="modclusterd" scontext=unconfined_u:system_r:ricci_modclusterd_t:s0 tcontext=system_u:object_r:port_t:s0 tclass=tcp_socket
type=SYSCALL msg=audit(1280782866.051:70): arch=c000003e syscall=42 success=no exit=-111 a0=6 a1=7f2510003140 a2=10 a3=40 items=0 ppid=1 pid=3507 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=2 comm


Here are both lines that show up in the audit.log file form the name_connect denial.  Please let me know if I should be including any other information.

Comment 8 Daniel Walsh 2010-08-03 19:40:33 UTC
Miroslav just allow this for now.  

corenet_tcp_connect_generic_port(ricci_modclusterd_t)

I think we will need

########################################
## <summary>
##	Read and write to ricci_modcluserd temporary file system.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`ricci_rw_modclusterd_tmpfs_files',`
	gen_require(`
		type ricci_modcluserd_tmpfs_t;
	')

	allow $1 ricci_modcluserd_tmpfs_t:file rw_file_perms;
')


And we might need
ricci_rw_modclusterd_tmpfs_files(corosync_t)????


The tmpfs files are being created by clustat.

Comment 9 Daniel Walsh 2010-08-03 19:50:32 UTC
SELinux guys, any idea why we are getting a name_connect avs without a dst field?

We can not identify which tcp port the modclusterd is trying to connect to.

Comment 10 Miroslav Grepl 2010-08-04 11:51:04 UTC
I have created one-node cluster and I am finally seeing the same issues. 

Dan, 
we definitely need to add

type ricci_modclusterd_tmpfs_t;
files_tmpfs_file(ricci_modclusterd_tmpfs_t)

manage_dirs_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, ricci_modclusterd_tmpfs_t)
manage_files_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, ricci_modclusterd_tmpfs_t)
fs_tmpfs_filetrans(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, { dir file })

kernel_request_load_module(ricci_modclusterd_t)
corenet_tcp_connect_generic_port(ricci_modclusterd_t)

optional_policy(`
 ricci_rw_modclusterd_tmpfs_files(corosync_t)
')

and 

interface(`ricci_rw_modclusterd_tmpfs_files',`
        gen_require(`
                type ricci_modclusterd_tmpfs_t;
        ')

        allow $1 ricci_modclusterd_tmpfs_t:file rw_file_perms;
        allow $1 ricci_modclusterd_tmpfs_t:file unlink;
')

Comment 11 Stephen Smalley 2010-08-04 18:40:37 UTC
(In reply to comment #9)
> SELinux guys, any idea why we are getting a name_connect avs without a dst
> field?
> 
> We can not identify which tcp port the modclusterd is trying to connect to.    

Can you run it under strace and attach the output for the failing connect() call?
Lack of dest= information suggests that either:
- the program is passing port 0 (which implies disconnect rather than connect; I didn't realize that was supported on TCP sockets), or
- we have a bug in the kernel in extracting the destination port or auditing it.

Comment 12 Miroslav Grepl 2010-08-06 18:22:22 UTC
(In reply to comment #10)
> I have created one-node cluster and I am finally seeing the same issues. 
> 
> Dan, 
> we definitely need to add
> 
> type ricci_modclusterd_tmpfs_t;
> files_tmpfs_file(ricci_modclusterd_tmpfs_t)
> 
> manage_dirs_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t,
> ricci_modclusterd_tmpfs_t)
> manage_files_pattern(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t,
> ricci_modclusterd_tmpfs_t)
> fs_tmpfs_filetrans(ricci_modclusterd_t, ricci_modclusterd_tmpfs_t, { dir file
> })
> 
> kernel_request_load_module(ricci_modclusterd_t)
> corenet_tcp_connect_generic_port(ricci_modclusterd_t)
> 
> optional_policy(`
>  ricci_rw_modclusterd_tmpfs_files(corosync_t)
> ')
> 
> and 
> 
> interface(`ricci_rw_modclusterd_tmpfs_files',`
>         gen_require(`
>                 type ricci_modclusterd_tmpfs_t;
>         ')
> 
>         allow $1 ricci_modclusterd_tmpfs_t:file rw_file_perms;
>         allow $1 ricci_modclusterd_tmpfs_t:file unlink;
> ')    

Rules was added to selinux-policy-3.7.19-36.el6.noarch

Comment 13 Chris Feist 2010-08-09 22:25:51 UTC
2783  connect(6, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.15.85.4")}, 16) = -1 EINVAL (Invalid argument)
2783  connect(6, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.15.85.4")}, 16) = -1 ECONNREFUSED (Connection refused)


Output from strace, it looks like it's trying to open a connection on port 0, I'm looking through the code to see where this is happening.

Comment 16 releng-rhel@redhat.com 2010-11-15 14:48:18 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.