Bug 632460 - SELinux is preventing /bin/mailx "read" access on /var/log/vsftpd.log-20100810.
Summary: SELinux is preventing /bin/mailx "read" access on /var/log/vsftpd.log-20...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 12
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: setroubleshoot_trace_hash:e5f254c80ab...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-10 02:14 UTC by Alfred Reaud
Modified: 2010-10-05 09:35 UTC (History)
4 users (show)

Fixed In Version: selinux-policy-3.7.19-62.fc13
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-10-05 09:35:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Alfred Reaud 2010-09-10 02:14:12 UTC
Summary:

SELinux is preventing /bin/mailx "read" access on /var/log/vsftpd.log-20100810.

Detailed Description:

[mail has a permissive type (system_mail_t). This access was not denied.]

SELinux denied access requested by mail. It is not expected that this access is
required by mail and this access may signal an intrusion attempt. It is also
possible that the specific version or configuration of the application is
causing it to require additional access.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug
report.

Additional Information:

Source Context                system_u:system_r:system_mail_t:s0-s0:c0.c1023
Target Context                system_u:object_r:xferlog_t:s0
Target Objects                /var/log/vsftpd.log-20100810 [ file ]
Source                        mail
Source Path                   /bin/mailx
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           mailx-12.4-3.fc12
Target RPM Packages           
Policy RPM                    selinux-policy-3.6.32-121.fc12
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   catchall
Host Name                     (removed)
Platform                      Linux xxxx 2.6.32.21-166.fc12.i686.PAE #1
                              SMP Fri Aug 27 06:33:34 UTC 2010 i686 athlon
Alert Count                   4
First Seen                    Sun 15 Aug 2010 03:41:17 AM MDT
Last Seen                     Sun 05 Sep 2010 03:09:14 AM MDT
Local ID                      ebd2058a-5816-43f6-b2a8-18e9aeb2d2df
Line Numbers                  

Raw Audit Messages            

node=HCTNET type=AVC msg=audit(1283677754.755:23015): avc:  denied  { read } for  pid=3456 comm="mail" path="/var/log/vsftpd.log-20100810" dev=dm-0 ino=60936 scontext=system_u:system_r:system_mail_t:s0-s0:c0.c1023 tcontext=system_u:object_r:xferlog_t:s0 tclass=file

node=HCTNET type=SYSCALL msg=audit(1283677754.755:23015): arch=40000003 syscall=11 success=yes exit=0 a0=8051c91 a1=bfe91c1c a2=bfe923b0 a3=bfe91c1c items=0 ppid=3337 pid=3456 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=33 comm="mail" exe="/bin/mailx" subj=system_u:system_r:system_mail_t:s0-s0:c0.c1023 key=(null)



Hash String generated from  catchall,mail,system_mail_t,xferlog_t,file,read
audit2allow suggests:

#============= system_mail_t ==============
allow system_mail_t xferlog_t:file read;

Comment 1 Alfred Reaud 2010-09-10 02:22:02 UTC
Reported to user operating as a limited user (non-root). The cause of the error is unknown, as the user was not accessing the email system at this time. However, log rotation will email the rotated log to the root user. But that should occur at approximately 4AM local time. This is a new error that started occurring after the upgrade to kernel .166.

Comment 2 Miroslav Grepl 2010-09-10 13:51:03 UTC
Do you use standard /etc/logrotate.d/vsftpd file?

# cat /etc/logrotate.d/vsftpd 
/var/log/vsftpd.log {
    # ftpd doesn't handle SIGHUP properly
    nocompress
    missingok
}

Comment 3 Daniel Walsh 2010-09-10 14:52:32 UTC
Are you trying to mail the xferlog_t ?  Are you using epylog?

Comment 4 Alfred Reaud 2010-09-11 14:01:29 UTC
@Miroslav: I'm using the following logrotate configuration for vsftpd

# cat /etc/logrotate.d/vsftpd
/var/log/vsftpd.log {
    # ftpd doesn't handle SIGHUP properly
    nocompress
    missingok
    mail root
}

@Daniel: epylog isn't installed. vstpd.log is selinux type xferlog_t, and so are the archive logs such as vstpd.log-20100905.

Comment 5 Daniel Walsh 2010-09-13 13:08:45 UTC
This looks like a leaked file descriptor from logrotate.

Does logrotate open this file for read?  If so, make sure you close the file descriptor on exec.

fcntl(fd, F_SETFD, FD_CLOEXEC)

Will do this.

Comment 6 Jan Kaluža 2010-09-15 17:28:14 UTC
Yes, logrotate opens that file and it looks it leaks file descriptors on exec. I will try to fix this issue, although, I'm not able to reproduce it here so far.

Comment 7 Jan Kaluža 2010-09-16 14:30:02 UTC
After some debugging I've found out logrotate doesn't set FD_CLOEXEC, but it closes descriptors "manually" before exec, so it should not leaks descriptors (I've also tested in in valgrind).

I've discussed it with Miroslav and I think the problem is that logrotate executes "mail" command (because of "mail root" directive in /etc/logrotate.d/vsftpd config file) and uses log file descriptor as stdin.

"mail" runs in system_mail_t domain, but vsftpd.log uses xferlog_t domain, so SELinux denies mail to read that file.

I'm not SELinux expert, so please correct me if I'm completely wrong.

Comment 8 Daniel Walsh 2010-09-16 16:04:25 UTC
So by adding the mail directive to a logrotate command means mail the log file to someone.  

Miroslav we need to do the same thing we did for logwatch.

Create a logrotate_mail_t.

#mta_send_mail(logrotate_t)
mta_base_mail_template(logrotate)
mta_sendmail_domtrans(logrotate_t, logrotate_mail_t)
role system_r types logrotate_mail_t;
logging_read_all_logs(logrotate_mail_t)
manage_files_pattern(logrotate_mail_t, logrotate_tmp_t, logrotate_tmp_t)

Comment 9 Miroslav Grepl 2010-09-21 13:33:10 UTC
Fixed in selinux-policy-3.7.19-60.fc13

Comment 10 Fedora Update System 2010-09-24 13:57:54 UTC
selinux-policy-3.7.19-62.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/selinux-policy-3.7.19-62.fc13

Comment 11 Fedora Update System 2010-09-26 04:31:53 UTC
selinux-policy-3.7.19-62.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/selinux-policy-3.7.19-62.fc13

Comment 12 Fedora Update System 2010-10-05 09:34:42 UTC
selinux-policy-3.7.19-62.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.