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 2029866 - SELinux prevents inotify on /etc/dnsmasq.d and tree under it
Summary: SELinux prevents inotify on /etc/dnsmasq.d and tree under it
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: 9.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 9.0
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-07 13:51 UTC by Riccardo Pittau
Modified: 2022-05-17 16:12 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-34.1.20-1.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 15:50:02 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-104989 0 None None None 2021-12-07 13:58:55 UTC
Red Hat Product Errata RHBA-2022:3918 0 None None None 2022-05-17 15:50:11 UTC

Description Riccardo Pittau 2021-12-07 13:51:39 UTC
Description of problem:
SELinux prevents inotify on /etc/dnsmasq.d and tree under it
the "watch" permission is missing on the dnsmasq_etc_t label


Version-Release number of selected component (if applicable):
dnsmasq-2.85-2.el9.x86_64
selinux-policy-34.1.18-1.el9.noarch
selinux-policy-targeted-34.1.18-1.el9.noarch

How reproducible:
100%

Steps to Reproduce:
1. set dhcp-hostsdir in dnsmasq configuration
2. start dnsmasq

Actual results:
example:
dnsmasq[9647]: failed to create inotify for /etc/dnsmasq.d/bifrost.dhcp-hosts.d: Permission denied

type=AVC msg=audit(1637861385.080:2976): avc:  denied  { watch } for  pid=17959 comm="dnsmasq" path="/etc/dnsmasq.d/bifrost.dhcp-hosts.d" dev="sda1" ino=452357 scontext=system_u:system_r:dnsmasq_t:s0 tcontext=unconfined_u:object_r:dnsmasq_etc_t:s0 tclass=dir permissive=0

Expected results:
should be able to set inotify on /etc/dnsmasq.d

Additional info:
after adding the "watch" permission to dnsmasq_etc_t everything works fine

Comment 1 Milos Malik 2021-12-07 14:44:08 UTC
# tail -n 2 /etc/dnsmasq.conf 
hostsdir=/etc/dnsmasq.d
# service dnsmasq restart
Redirecting to /bin/systemctl restart dnsmasq.service
#

Following SELinux denial appeared in enforcing mode:
----
type=PROCTITLE msg=audit(12/07/2021 09:38:48.124:320) : proctitle=/usr/sbin/dnsmasq 
type=PATH msg=audit(12/07/2021 09:38:48.124:320) : item=0 name=/etc/dnsmasq.d inode=29360448 dev=fd:01 mode=dir,755 ouid=root ogid=dnsmasq rdev=00:00 obj=system_u:object_r:dnsmasq_etc_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(12/07/2021 09:38:48.124:320) : cwd=/ 
type=SYSCALL msg=audit(12/07/2021 09:38:48.124:320) : arch=x86_64 syscall=inotify_add_watch success=no exit=EACCES(Permission denied) a0=0x8 a1=0x5586fa914c70 a2=0x88 a3=0x0 items=1 ppid=1 pid=5720 auid=unset uid=dnsmasq gid=dnsmasq euid=dnsmasq suid=dnsmasq fsuid=dnsmasq egid=dnsmasq sgid=dnsmasq fsgid=dnsmasq tty=(none) ses=unset comm=dnsmasq exe=/usr/sbin/dnsmasq subj=system_u:system_r:dnsmasq_t:s0 key=(null) 
type=AVC msg=audit(12/07/2021 09:38:48.124:320) : avc:  denied  { watch } for  pid=5720 comm=dnsmasq path=/etc/dnsmasq.d dev="vda1" ino=29360448 scontext=system_u:system_r:dnsmasq_t:s0 tcontext=system_u:object_r:dnsmasq_etc_t:s0 tclass=dir permissive=0 
----

Following SELinux denial appeared in permissive mode:
----
type=PROCTITLE msg=audit(12/07/2021 09:41:03.126:326) : proctitle=/usr/sbin/dnsmasq 
type=PATH msg=audit(12/07/2021 09:41:03.126:326) : item=0 name=/etc/dnsmasq.d inode=29360448 dev=fd:01 mode=dir,755 ouid=root ogid=dnsmasq rdev=00:00 obj=system_u:object_r:dnsmasq_etc_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0 
type=CWD msg=audit(12/07/2021 09:41:03.126:326) : cwd=/ 
type=SYSCALL msg=audit(12/07/2021 09:41:03.126:326) : arch=x86_64 syscall=inotify_add_watch success=yes exit=2 a0=0x8 a1=0x556fd368bc70 a2=0x88 a3=0x0 items=1 ppid=1 pid=5733 auid=unset uid=dnsmasq gid=dnsmasq euid=dnsmasq suid=dnsmasq fsuid=dnsmasq egid=dnsmasq sgid=dnsmasq fsgid=dnsmasq tty=(none) ses=unset comm=dnsmasq exe=/usr/sbin/dnsmasq subj=system_u:system_r:dnsmasq_t:s0 key=(null) 
type=AVC msg=audit(12/07/2021 09:41:03.126:326) : avc:  denied  { watch } for  pid=5733 comm=dnsmasq path=/etc/dnsmasq.d dev="vda1" ino=29360448 scontext=system_u:system_r:dnsmasq_t:s0 tcontext=system_u:object_r:dnsmasq_etc_t:s0 tclass=dir permissive=1 
----

Comment 3 Zdenek Pytela 2021-12-07 17:10:32 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/969

Comment 5 Zdenek Pytela 2021-12-09 19:34:01 UTC
To backport:
commit 359d7cdc59a69c39c9f1d00890002dc7150b918a (HEAD -> rawhide, upstream/rawhide)
Author: Zdenek Pytela <zpytela>
Date:   Tue Dec 7 18:08:01 2021 +0100

    Allow dnsmasq watch /etc/dnsmasq.d directories

Comment 13 errata-xmlrpc 2022-05-17 15:50:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: selinux-policy), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3918


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