Bug 1290876

Summary: SELinux prevents DSPAM to read its own data files when acting as a LDA
Product: [Fedora] Fedora Reporter: Gustavo Maciel Dias Vieira <gustavo>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 27CC: dominick.grift, dwalsh, lvrabec, mgrepl, plautrba
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-283.21.fc27 selinux-policy-3.13.1-283.24.fc27 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-06 15:31:46 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:

Description Gustavo Maciel Dias Vieira 2015-12-11 18:30:41 UTC
Description of problem:
If I setup DSPAM to act as LDA, SELinux blocks its access to its own data files, marked as dspam_rw_content_t. A really strange bug.

Version-Release number of selected component (if applicable):
dspam-3.10.2-18.fc23.x86_64
selinux-policy-3.13.1-155.fc23.noarch


How reproducible:
Deterministic


Steps to Reproduce:

My setup is this: I use Postfix as MDA and configured it to deliver mail to DSPAM with:

   mailbox_command = /usr/bin/dspam --deliver=innocent,spam

DSPAM is configured to process the message, tag it and pass it to be delived by Procmail with:

   TrustedDeliveryAgent "/usr/bin/procmail"
   UntrustedDeliveryAgent "/usr/bin/procmail"

Procmail will, as usual, parse the ~/.procmailrc file and deliver the message to /var/spool/mail or any other user writeable directory indicated in procmailrc.

The whole setup works perfectly in permissive mode.

Comment 1 Gustavo Maciel Dias Vieira 2015-12-11 18:31:29 UTC
Here are the AVCs:

type=AVC msg=audit(1449843945.665:1053): avc:  denied  { getattr } for  pid=2801 comm="dspam" path="/var/lib/dspam/data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1449843945.666:1054): avc:  denied  { append } for  pid=2801 comm="dspam" name="rootmail.lock" dev="sdb1" ino=402981 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1449843945.666:1055): avc:  denied  { open } for  pid=2801 comm="dspam" path="/var/lib/dspam/data/r/o/rootmail/rootmail.lock" dev="sdb1" ino=402981 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1449843945.667:1056): avc:  denied  { lock } for  pid=2801 comm="dspam" path="/var/lib/dspam/data/r/o/rootmail/rootmail.lock" dev="sdb1" ino=402981 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1449843945.667:1057): avc:  denied  { read write } for  pid=2801 comm="dspam" name="rootmail.css" dev="sdb1" ino=405885 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1449843945.682:1058): avc:  denied  { write } for  pid=2801 comm="dspam" name="rootmail.sig" dev="sdb1" ino=402992 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1449843945.682:1059): avc:  denied  { add_name } for  pid=2801 comm="dspam" name="566adce928011989883163.sig" scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1449843945.683:1060): avc:  denied  { create } for  pid=2801 comm="dspam" name="566adce928011989883163.sig" scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1449843945.684:1061): avc:  denied  { getattr } for  pid=2801 comm="dspam" path="/var/lib/dspam/data/r/o/rootmail/rootmail.sig/566adce928011989883163.sig" dev="sdb1" ino=399871 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1


type=AVC msg=audit(1449849109.739:1765): avc:  denied  { search } for  pid=26287 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1449849109.740:1766): avc:  denied  { search } for  pid=26287 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1449849109.741:1767): avc:  denied  { search } for  pid=26287 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1449849109.743:1768): avc:  denied  { search } for  pid=26287 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0

Comment 2 Gustavo Maciel Dias Vieira 2015-12-11 18:33:31 UTC
If I take the AVCs in permissive mode and run audit2allow, I get:

#============= dspam_t ==============
allow dspam_t dspam_rw_content_t:dir { write getattr add_name search };
allow dspam_t dspam_rw_content_t:file { create read lock write getattr open append };


I made this into a module and installed it and DSPAM works in enforcing mode.

This bug is really strange, why isn't DSPAM able to RW dspam_rw_content_t?

Comment 3 Fedora Admin XMLRPC Client 2016-09-27 14:57:58 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 4 Fedora End Of Life 2016-11-24 14:10:22 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2016-12-20 16:56:01 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 6 Gustavo Maciel Dias Vieira 2017-12-15 18:27:24 UTC
This bug is alive and well in Fedora 27.

I will update the version numbers and the AVCs, but the remaining data is the same.

dspam-3.10.2-24.fc27.x86_64
selinux-policy-3.13.1-283.17.fc27.noarch

AVCs:

type=SERVICE_START msg=audit(1513358925.979:377): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=postfix comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=AVC msg=audit(1513358936.788:378): avc:  denied  { getattr } for  pid=5643 comm="dspam" path="/var/lib/dspam/data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1513358936.789:379): avc:  denied  { append } for  pid=5643 comm="dspam" name="gustavo.lock" dev="sdb1" ino=392676 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.789:380): avc:  denied  { open } for  pid=5643 comm="dspam" path="/var/lib/dspam/data/g/u/gustavo/gustavo.lock" dev="sdb1" ino=392676 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.789:381): avc:  denied  { lock } for  pid=5643 comm="dspam" path="/var/lib/dspam/data/g/u/gustavo/gustavo.lock" dev="sdb1" ino=392676 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.789:382): avc:  denied  { read write } for  pid=5643 comm="dspam" name="gustavo.css" dev="sdb1" ino=401691 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.789:383): avc:  denied  { map } for  pid=5643 comm="dspam" path="/var/lib/dspam/data/g/u/gustavo/gustavo.css" dev="sdb1" ino=401691 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.819:384): avc:  denied  { write } for  pid=5643 comm="dspam" name="gustavo.sig" dev="sdb1" ino=392509 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1513358936.819:385): avc:  denied  { add_name } for  pid=5643 comm="dspam" name="5a34065856431320019210.sig" scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1513358936.819:386): avc:  denied  { create } for  pid=5643 comm="dspam" name="5a34065856431320019210.sig" scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=AVC msg=audit(1513358936.820:387): avc:  denied  { getattr } for  pid=5643 comm="dspam" path="/var/lib/dspam/data/g/u/gustavo/gustavo.sig/5a34065856431320019210.sig" dev="sdb1" ino=401220 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1
type=SERVICE_STOP msg=audit(1513358945.997:388): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=postfix comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1513359882.247:397): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=postfix comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=AVC msg=audit(1513359893.034:398): avc:  denied  { search } for  pid=5920 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1513359893.034:399): avc:  denied  { search } for  pid=5920 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1513359893.034:400): avc:  denied  { search } for  pid=5920 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1513359893.035:401): avc:  denied  { search } for  pid=5920 comm="dspam" name="dspam-data" dev="sdb1" ino=392499 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=dir permissive=0
type=SERVICE_STOP msg=audit(1513359909.880:402): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=postfix comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

Comment 7 Fedora Update System 2018-01-04 12:09:47 UTC
selinux-policy-3.13.1-283.20.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-0d8506aba4

Comment 8 Fedora Update System 2018-01-05 11:58:17 UTC
selinux-policy-3.13.1-283.20.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-0d8506aba4

Comment 9 Fedora Update System 2018-01-05 14:48:34 UTC
selinux-policy-3.13.1-283.21.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-0d8506aba4

Comment 10 Fedora Update System 2018-01-06 21:08:16 UTC
selinux-policy-3.13.1-283.21.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-0d8506aba4

Comment 11 Fedora Update System 2018-01-10 02:06:18 UTC
selinux-policy-3.13.1-283.21.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 12 Gustavo Maciel Dias Vieira 2018-01-15 21:39:47 UTC
Lukas, thank you! This bug was open for two years!

Unfortunately, I suppose I misled you and actually there is one AVC that changed from F23 to F27 and, as consequence, persists in the current policy:

type=AVC msg=audit(1516051670.662:570): avc:  denied  { map } for  pid=6683 comm="dspam" path="/var/lib/dspam/data/g/u/gustavo/gustavo.css" dev="sdb1" ino=404595 scontext=system_u:system_r:dspam_t:s0 tcontext=system_u:object_r:dspam_rw_content_t:s0 tclass=file permissive=1

audit2allow:

#============= dspam_t ==============
allow dspam_t dspam_rw_content_t:file map;


I'm really sorry about this. I should have posted the module I was using.

Comment 13 Lukas Vrabec 2018-01-23 12:36:41 UTC
commit d673d266f4d6e1ea107bc0a03be1b1d023806a77 (HEAD -> f27, origin/f27)
Author: Lukas Vrabec <lvrabec>
Date:   Tue Jan 2 16:45:51 2018 +0100

    Allow dspam_t to mmap dspam_rw_content_t files BZ(1528723)


Backported to F27

Comment 14 Fedora Update System 2018-01-30 16:41:45 UTC
selinux-policy-3.13.1-283.24.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-a144eca5a8

Comment 15 Fedora Update System 2018-01-31 22:45:14 UTC
selinux-policy-3.13.1-283.24.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-a144eca5a8

Comment 16 Fedora Update System 2018-02-06 15:31:46 UTC
selinux-policy-3.13.1-283.24.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.