Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 901945

Summary: syslog-ng 3.3.8 selinux violations
Product: Red Hat Enterprise Linux 6 Reporter: Jose Pedro Oliveira <jose.p.oliveira.oss>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED WORKSFORME QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3CC: dwalsh, mmalik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-23 12:44:56 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: 871960    

Description Jose Pedro Oliveira 2013-01-20 04:13:59 UTC
Description of problem:
Due to the imminent EOL of syslog-ng 3.2.x (available in the EPEL6 repos) we are planning to upgrade it to version 3.3.8 (or maybe to the future 3.4 version).
During the package of syslog-ng 3.3.x to EPEL6 (#871960) we have come across
a couple of SElinux violations that don't occur in Fedora 18.

Version-Release number of selected component (if applicable):
selinux-policy-3.7.19-155.el6_3.14

How reproducible:
Always

Steps to Reproduce:
1. install syslog-ng-3.3.8-0.1 (SRPM in the ticket #871960)
2. change the selinux policy to permissive
3. chkconfig rsyslog off; chkconfig syslog-ng on
4. service rsyslog stop; service syslog-ng start
  
Actual results:
cat /var/log/audit/audit.log | audit2allow
----------
#============= syslogd_t ==============
allow syslogd_t anon_inodefs_t:file { write read };
allow syslogd_t self:process { getcap setcap };
----------

Expected results:
Be able to run syslog-ng 3.3.8 in selinux enforcing mode

Additional info:
The audit2allow rules are created from these audit.log messages:

type=AVC msg=audit(1358658647.269:14): avc:  denied  { getcap } for  pid=1239 comm="syslog-ng" scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:system_r:syslogd_t:s0 tclass=process
type=SYSCALL msg=audit(1358658647.269:14): arch=c000003e syscall=125 success=no exit=-14 a0=101dfa4 a1=0 a2=c60 a3=24 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

type=AVC msg=audit(1358658647.269:15): avc:  denied  { setcap } for  pid=1239 comm="syslog-ng" scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:system_r:syslogd_t:s0 tclass=process
type=SYSCALL msg=audit(1358658647.269:15): arch=c000003e syscall=126 success=yes exit=0 a0=101dfd4 a1=101dfdc a2=1 a3=0 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

type=AVC msg=audit(1358658647.556:16): avc:  denied  { write } for  pid=1239 comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
type=SYSCALL msg=audit(1358658647.556:16): arch=c000003e syscall=1 success=yes exit=8 a0=6 a1=7fff1a464128 a2=8 a3=1 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

type=AVC msg=audit(1358658647.556:17): avc:  denied  { read } for  pid=1239 comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
type=SYSCALL msg=audit(1358658647.556:17): arch=c000003e syscall=0 success=yes exit=8 a0=6 a1=7fff1a464140 a2=8 a3=25f3 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

Comment 2 Miroslav Grepl 2013-01-21 10:56:15 UTC
I am adding setcap/getcap.

type=AVC msg=audit(1358658647.556:16): avc:  denied  { write } for  pid=1239 comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
type=SYSCALL msg=audit(1358658647.556:16): arch=c000003e syscall=1 success=yes exit=8 a0=6 a1=7fff1a464128 a2=8 a3=1 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

type=AVC msg=audit(1358658647.556:17): avc:  denied  { read } for  pid=1239 comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
type=SYSCALL msg=audit(1358658647.556:17): arch=c000003e syscall=0 success=yes exit=8 a0=6 a1=7fff1a464140 a2=8 a3=25f3 items=0 ppid=1238 pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)

looks like a leak.

Did you get in enforcing mode?

Comment 3 Jose Pedro Oliveira 2013-01-21 13:23:36 UTC
(In reply to comment #2)
> I am adding setcap/getcap.

Thanks!

> type=AVC msg=audit(1358658647.556:16): avc:  denied  { write } for  pid=1239
> comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019
> scontext=system_u:system_r:syslogd_t:s0
> tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
> type=SYSCALL msg=audit(1358658647.556:16): arch=c000003e syscall=1
> success=yes exit=8 a0=6 a1=7fff1a464128 a2=8 a3=1 items=0 ppid=1238 pid=1239
> auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0
> tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng"
> subj=system_u:system_r:syslogd_t:s0 key=(null)
> 
> type=AVC msg=audit(1358658647.556:17): avc:  denied  { read } for  pid=1239
> comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019
> scontext=system_u:system_r:syslogd_t:s0
> tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
> type=SYSCALL msg=audit(1358658647.556:17): arch=c000003e syscall=0
> success=yes exit=8 a0=6 a1=7fff1a464140 a2=8 a3=25f3 items=0 ppid=1238
> pid=1239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0
> fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng"
> subj=system_u:system_r:syslogd_t:s0 key=(null)
> 
> looks like a leak.
> 
> Did you get in enforcing mode?

I'm running the system in permissive mode: syslog-ng stops logging messages
if I change the selinux policy to enforcing mode (echo 1 > /selinux/enforce).


/jpo

Comment 4 Miroslav Grepl 2013-01-22 06:05:16 UTC
If you add the following local policy

# cat mypol.te
policy_module(mypol,1.0)

require{
 type syslogd_t;
}

allow syslogd_t self:process { getcap setcap };




and then execute

# make -f /usr/share/selinux/devel/Makefile mypol.pp
# semodule -i mypol.pp

Does it work then?

Comment 5 Jose Pedro Oliveira 2013-01-22 21:33:12 UTC
I'm no longer get the setcap/getcap violations with the above policy.

[selinux policy in enforcing mode]
But syslog-ng, although it is running, isn't able of writing the log messages
to their destinations (tailing /var/log/messages). When I do a "setenforce permissive" and restart syslog-ng, it writes the buffered kernel messages.

/jpo

Comment 6 Daniel Walsh 2013-01-22 21:41:30 UTC
Sounds like a labeling issue.

restorecon -R -v /var/log

Also make sure syslog-ng is running as syslogd_t.

ps -eZ | grep syslog

Finally check if there are any new AVC messages.

Comment 7 Jose Pedro Oliveira 2013-01-23 00:43:30 UTC
(In reply to comment #6)
> Sounds like a labeling issue.
> 
> restorecon -R -v /var/log
> 
> Also make sure syslog-ng is running as syslogd_t.
> 
> ps -eZ | grep syslog
> 
> Finally check if there are any new AVC messages.


Still no luck 

# restorecon -R -v /var/log

# cat /selinux/enforce 
1

# ps -eZ | grep syslog
system_u:system_r:syslogd_t:s0   1299 ?        00:00:00 syslog-ng
system_u:system_r:syslogd_t:s0   1300 ?        00:00:00 syslog-ng

No new syslog related messages in audit.log. Just this one:
---------
type=AVC msg=audit(1358904543.846:10): avc:  denied  { write } for  pid=1300 comm="syslog-ng" path="anon_inode:[eventfd]" dev=anon_inodefs ino=4019 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:anon_inodefs_t:s0 tclass=file
type=SYSCALL msg=audit(1358904543.846:10): arch=c000003e syscall=1 success=no exit=-13 a0=6 a1=7fff2e5a9128 a2=8 a3=1 items=0 ppid=1299 pid=1300 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="syslog-ng" exe="/sbin/syslog-ng" subj=system_u:system_r:syslogd_t:s0 key=(null)
--------



syslog-ng 3.3+ uses a new support library for asynchronous I/O notification (ivykis). strace -p syslog_ng_pid shows the following syscall being made (selinux permissive mode):

      epoll_wait(3, ...

Don't know if this helps...

/jpo

Comment 8 Miroslav Grepl 2013-01-23 07:53:08 UTC
Ok, please re-test it with


# cat mypol.te
policy_module(mypol,1.0)

require{
 type syslogd_t;
 type anon_inodefs_t;
}

allow syslogd_t self:process { getcap setcap };
allow syslogd_t anon_inodefs_t:file { write read };

Comment 9 Jose Pedro Oliveira 2013-01-23 13:29:54 UTC
(In reply to comment #8)
> Ok, please re-test it with
> 
> 
> # cat mypol.te
> policy_module(mypol,1.0)
> 
> require{
>  type syslogd_t;
>  type anon_inodefs_t;
> }
> 
> allow syslogd_t self:process { getcap setcap };
> allow syslogd_t anon_inodefs_t:file { write read };

syslog-ng now operates correctly under selinux enforcing mode (and no syslog-ng related messages in audit.log).

Thanks,
jpo

Comment 10 RHEL Program Management 2013-01-27 06:47:33 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 12 Jose Pedro Oliveira 2013-05-23 01:39:31 UTC
This ticket can be closed (I don't have permissions to close it).

syslog-ng 3.3.8 works fine in a freshly installed CentOS 6.4 x86_64 system with selinux-policy-3.7.19-195.el6_4.5.noarch.