Bug 698398

Summary: mimedefang.pl's invocation of send_mail() causes an exception
Product: [Fedora] Fedora Reporter: Philip Prindeville <philipp>
Component: selinux-policy-targetedAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 16CC: dwalsh, philipp
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.10.0-61.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-30 01:59:54 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:

Description Philip Prindeville 2011-04-20 19:44:40 UTC
Description of problem:

If a user's homegrown mimedefang-filter should invoke send_mail() to deliver a message to a quarantine or postmaster mailbox (as we do locally) instead of using procmail to do so, this may cause the following issues:

Apr 19 23:55:30 mail setroubleshoot: SELinux is preventing /usr/sbin/sendmail.sendmail from execute access on the file /usr/sbin/sendmail.sendmail. For complete SELinux messages. run sealert -l 663766c4-a1d7-4269-a46c-9bc7952715b7

# sealert -l 663766c4-a1d7-4269-a46c-9bc7952715b7

SELinux is preventing /usr/sbin/sendmail.sendmail from execute access on the file /usr/sbin/sendmail.sendmail.

*****  Plugin catchall (100. confidence) suggests  ***************************

If you believe that sendmail.sendmail should be allowed execute access on the sendmail.sendmail file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep sendmail /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp


and:

# ausearch -m avc -ts yesterday
...

----
time->Tue Apr 19 23:55:26 2011
type=SYSCALL msg=audit(1303278926.552:27677): arch=c000003e syscall=59 success=no exit=-13 a0=4c0a0a0 a1=4dd1a70 a2=e2f140 a3=8 items=0 ppid=12394 pid=13086 auid=4294967295 uid=491 gid=478 euid=491 suid=491 fsuid=491 egid=478 sgid=478 fsgid=478 tty=(none) ses=4294967295 comm="mimedefang.pl" exe="/usr/bin/perl" subj=system_u:system_r:spamd_t:s0 key=(null)
type=AVC msg=audit(1303278926.552:27677): avc:  denied  { execute } for  pid=13086 comm="mimedefang.pl" name="sendmail.sendmail" dev=sda3 ino=267135 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file
----
time->Tue Apr 19 23:55:26 2011
type=SYSCALL msg=audit(1303278926.626:27678): arch=c000003e syscall=59 success=no exit=-13 a0=4c0a0a0 a1=4b431b0 a2=e2f140 a3=8 items=0 ppid=12394 pid=13089 auid=4294967295 uid=491 gid=478 euid=491 suid=491 fsuid=491 egid=478 sgid=478 fsgid=478 tty=(none) ses=4294967295 comm="mimedefang.pl" exe="/usr/bin/perl" subj=system_u:system_r:spamd_t:s0 key=(null)
type=AVC msg=audit(1303278926.626:27678): avc:  denied  { execute } for  pid=13089 comm="mimedefang.pl" name="sendmail.sendmail" dev=sda3 ino=267135 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file



Version-Release number of selected component (if applicable):

selinux-policy-targeted-3.9.7-37.fc14.noarch


How reproducible:

Call send_mail() from within mimedefang-filter with a message to deliver.

Steps to Reproduce:
1.
2.
3.

Actual results:

If policy is "enforcing", the delivery will fail and mimedefang will report that a delivery error occurred, causing the sender to reattempt delivery later. Eventually the sender will time out and give up (after 5 days or so).


Expected results:

Even with policy "enforcing", this is a legitimate scenario to have mimedefang deliver quarantined messages into postmaster's mailbox.


Additional info:

Comment 1 Philip Prindeville 2011-04-20 19:47:50 UTC
dgrift provided the following sample fix:


policy_module(myspamd, 1.0.0)
gen_require(` type spamd_t; ')
mta_send_mail(spamd_t)


which seems to be working.

Comment 2 Miroslav Grepl 2011-04-21 06:53:41 UTC
Looks fine. Will add.

Comment 3 Philip Prindeville 2011-05-06 04:21:07 UTC
Please let me know when it's been checked in so I can do a mockbuild and try it out.

Comment 4 Philip Prindeville 2011-05-10 05:05:05 UTC
When is the next release of selinux-policy due out?

Comment 5 Miroslav Grepl 2011-05-10 06:28:51 UTC
A new build will be available from koji today.

Comment 6 Philip Prindeville 2011-05-11 17:54:35 UTC
(In reply to comment #5)
> A new build will be available from koji today.

Can you post the URL?  Thanks.

Comment 8 Philip Prindeville 2011-05-13 17:35:05 UTC
(In reply to comment #7)
> http://koji.fedoraproject.org/koji/buildinfo?buildID=243234

Please also provide an f15 build.

Comment 9 Miroslav Grepl 2011-05-17 14:04:02 UTC
It should be fixed in the latest F15 policy.

Comment 10 Philip Prindeville 2011-05-24 03:10:39 UTC
Seeing:

type=AVC msg=audit(1303278926.626:27678): avc:  denied  { execute } for  pid=13089 comm="mimedefang.pl" name="sendmail.sendmail" dev=sda3 ino=267135 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file

	Was caused by:
		Unknown - would be allowed by active policy
		Possible mismatch between this policy and the one under which the audit message was generated.

		Possible mismatch between current in-memory boolean settings vs. permanent ones.

Comment 11 Miroslav Grepl 2011-05-24 06:15:06 UTC
Philip,

try to execute

# yum reinstall selinux-policy-targeted

Comment 12 Philip Prindeville 2011-05-29 00:53:28 UTC
Hmmm...  hard to tell. I did that, but running:

audit2why < /var/log/audit/audit.log

doesn't bother to give me recognizable timestamps, so it's hard to tell if the last occurrence of that message was before or after refreshing the package.

Is there a way to get audit2why to spew meaningful timestamps instead of seconds since the epoch (which I have to admit, I can't convert in my head)...

Ok, doing a little work:


[philipp@builder ~]$ cat /tmp/y2
#!/usr/bin/perl

my $sec = 1303278926;

use POSIX qw(strftime);

print strftime("%a %b %e %H:%M:%S %Y", localtime($sec)), "\n";
[philipp@builder ~]$ /tmp/y2
Tue Apr 19 23:55:26 2011
[philipp@builder ~]$ 

Ok, so it seems that I've not seen it in a while.

Comment 13 Daniel Walsh 2011-05-31 16:07:59 UTC
ausearch is the tool that will translate the time stamps, I also run it with the -i flag to translate UID and syscall info.

Comment 14 Philip Prindeville 2011-06-11 22:21:21 UTC
(In reply to comment #11)
> Philip,
> 
> try to execute
> 
> # yum reinstall selinux-policy-targeted

It seems to be working. Please go ahead and close this.

I'm running:

selinux-policy-targeted-3.9.16-26.fc15.noarch

without incident.

Comment 15 Miroslav Grepl 2011-06-13 10:36:04 UTC
Ok, thanks.

Comment 16 Philip Prindeville 2011-11-23 22:53:31 UTC
This seems to have regressed.

type=AVC msg=audit(11/23/2011 00:07:37.218:572) : avc:  denied  { execute } for  pid=11464 comm=mimedefang.pl name=sendmail.sendmail dev=sda3 ino=266985 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file 
type=AVC msg=audit(11/23/2011 00:07:37.339:573) : avc:  denied  { execute } for  pid=11467 comm=mimedefang.pl name=sendmail.sendmail dev=sda3 ino=266985 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file 
type=AVC msg=audit(11/23/2011 01:01:57.074:583) : avc:  denied  { execute } for  pid=11623 comm=mimedefang.pl name=sendmail.sendmail dev=sda3 ino=266985 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file 
type=AVC msg=audit(11/23/2011 01:01:57.196:584) : avc:  denied  { execute } for  pid=11626 comm=mimedefang.pl name=sendmail.sendmail dev=sda3 ino=266985 scontext=system_u:system_r:spamd_t:s0 tcontext=system_u:object_r:sendmail_exec_t:s0 tclass=file

I'm running:

selinux-policy-targeted-3.10.0-56.fc16.noarch
selinux-policy-3.10.0-56.fc16.noarch

Comment 17 Philip Prindeville 2011-11-24 01:06:33 UTC
audit2allow tells me we need:

module mimedefang 1.0;

require {
	type spamd_t;
	type sendmail_exec_t;
	class file execute;
}

#============= spamd_t ==============
allow spamd_t sendmail_exec_t:file execute;


or at least merge this with existing policy.

Comment 18 Miroslav Grepl 2011-11-24 09:51:30 UTC
Added to F16.

Comment 19 Fedora Update System 2011-11-24 13:22:04 UTC
selinux-policy-3.10.0-59.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/selinux-policy-3.10.0-59.fc16

Comment 20 Fedora Update System 2011-11-25 02:17:21 UTC
Package selinux-policy-3.10.0-60.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-60.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-16371/selinux-policy-3.10.0-60.fc16
then log in and leave karma (feedback).

Comment 21 Fedora Update System 2011-11-25 23:25:44 UTC
Package selinux-policy-3.10.0-61.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-61.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-16371/selinux-policy-3.10.0-61.fc16
then log in and leave karma (feedback).

Comment 22 Philip Prindeville 2011-11-26 00:00:32 UTC
(In reply to comment #21)
> Package selinux-policy-3.10.0-61.fc16:
> * should fix your issue,
> * was pushed to the Fedora 16 testing repository,
> * should be available at your local mirror within two days.
> Update it with:
> # su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-61.fc16'
> as soon as you are able to.
> Please go to the following url:
> https://admin.fedoraproject.org/updates/FEDORA-2011-16371/selinux-policy-3.10.0-61.fc16
> then log in and leave karma (feedback).

Was there a reason to not fix 753962 in build .61?

Comment 23 Miroslav Grepl 2011-11-28 11:13:51 UTC
yes, i was ill and 60, 61 releases contain only q spec file change, not policy changes.

Comment 24 Fedora Update System 2011-11-30 01:59:54 UTC
selinux-policy-3.10.0-61.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 25 Philip Prindeville 2011-11-30 23:11:22 UTC
Is this in master/rawhide as well as f16?

Comment 26 Miroslav Grepl 2011-12-01 08:12:04 UTC
Yes, it is.