Bug 2246115 - SELinux prevents the smtpctl process from connecting to the /run/smtpd.sock socket
Summary: SELinux prevents the smtpctl process from connecting to the /run/smtpd.sock s...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: rawhide
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-10-25 13:15 UTC by Milos Malik
Modified: 2023-12-18 13:45 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-12-18 13:45:55 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github fedora-selinux selinux-policy pull 1927 0 None open Allow sendmail LDA connect to sendmail MTA 2023-11-02 18:19:10 UTC

Description Milos Malik 2023-10-25 13:15:27 UTC
The following messages appear in the systemd journal:

smtpd[4696]: warn: smtpd: couldn't enqueue offline message /var/spool/smtpd/offline/1698239121.XXXXgdWAzf; smtpctl exited abnormally
smtpd[4696]: warn: smtpd: couldn't enqueue offline message /var/spool/smtpd/offline/1698239146.XXXXn6KRCk; smtpctl exited abnormally


Reproducible: Always

Steps to Reproduce:
1. get a Fedora rawhide machine (targeted policy is active)
2. write an email to somebody
(for example: mailx -s test-subject somebody@somewhere)
3. run the following automated test
 * https://src.fedoraproject.org/tests/selinux/blob/main/f/selinux-policy/opensmtpd-and-similar
4. search for SELinux denials

Actual Results:  
----
type=PROCTITLE msg=audit(10/25/2023 09:05:57.688:665) : proctitle=sendmail -S -i -- mmalik 
type=PATH msg=audit(10/25/2023 09:05:57.688:665) : item=0 name=/var/run/smtpd.sock inode=1456 dev=00:19 mode=socket,666 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:sendmail_var_run_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(10/25/2023 09:05:57.688:665) : cwd=/root 
type=SOCKADDR msg=audit(10/25/2023 09:05:57.688:665) : saddr={ saddr_fam=local path=/var/run/smtpd.sock } 
type=SYSCALL msg=audit(10/25/2023 09:05:57.688:665) : arch=x86_64 syscall=connect success=no exit=EACCES(Permission denied) a0=0x4 a1=0x7ffd1b525310 a2=0x6e a3=0x55fbfb1c3790 items=1 ppid=4696 pid=4761 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=smtpq sgid=smtpq fsgid=smtpq tty=(none) ses=unset comm=smtpctl exe=/usr/sbin/smtpctl subj=system_u:system_r:sendmail_t:s0 key=(null) 
type=AVC msg=audit(10/25/2023 09:05:57.688:665) : avc:  denied  { connectto } for  pid=4761 comm=smtpctl path=/run/smtpd.sock scontext=system_u:system_r:sendmail_t:s0 tcontext=system_u:system_r:sendmail_t:s0 tclass=unix_stream_socket permissive=0 
----

Expected Results:  
No SELinux denials. No error messages in the systemd journal.

Comment 1 Milos Malik 2023-10-25 13:19:09 UTC
The following SELinux denial appeared in permissive mode:
----
type=PROCTITLE msg=audit(10/25/2023 09:15:55.743:682) : proctitle=sendmail -S -S -i -- mmalik
type=PATH msg=audit(10/25/2023 09:15:55.743:682) : item=0 name=/var/run/smtpd.sock inode=1467 dev=00:19 mode=socket,666 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:sendmail_var_run_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(10/25/2023 09:15:55.743:682) : cwd=/root 
type=SOCKADDR msg=audit(10/25/2023 09:15:55.743:682) : saddr={ saddr_fam=local path=/var/run/smtpd.sock } 
type=SYSCALL msg=audit(10/25/2023 09:15:55.743:682) : arch=x86_64 syscall=connect success=yes exit=0 a0=0x4 a1=0x7fff78c65450 a2=0x6e a3=0x56061c9e6790 items=1 ppid=7455 pid=7523 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=smtpq sgid=smtpq fsgid=smtpq tty=(none) ses=unset comm=smtpctl exe=/usr/sbin/smtpctl subj=system_u:system_r:sendmail_t:s0 key=(null) 
type=AVC msg=audit(10/25/2023 09:15:55.743:682) : avc:  denied  { connectto } for  pid=7523 comm=smtpctl path=/run/smtpd.sock scontext=system_u:system_r:sendmail_t:s0 tcontext=system_u:system_r:sendmail_t:s0 tclass=unix_stream_socket permissive=1 
----

# rpm -qa selinux\* opensmtp\* | sort
opensmtpd-6.8.0p2-12.fc39.x86_64
selinux-policy-40.4-1.fc40.noarch
selinux-policy-devel-40.4-1.fc40.noarch
selinux-policy-targeted-40.4-1.fc40.noarch
#

Comment 2 Milos Malik 2023-10-25 17:04:17 UTC
Test coverage for this BZ exists in a form of PR:
 * https://src.fedoraproject.org/tests/selinux/pull-request/443

The PR waits for a review.


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