Bug 2013595

Summary: SELinux is preventing /usr/sbin/named from 'name_bind' accesses on the udp_socket port 61000.
Product: Red Hat Enterprise Linux 9 Reporter: Petr Menšík <pemensik>
Component: bindAssignee: Petr Menšík <pemensik>
Status: CLOSED ERRATA QA Contact: Petr Sklenar <psklenar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: lvrabec, mmalik, plautrba, psklenar, rhel-cs-infra-services-qe, ssekidde, tselios.petros, zpytela
Target Milestone: rcKeywords: TestCaseProvided, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: bind-9.16.20-5.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1950714 Environment:
Last Closed: 2022-05-17 13:24:10 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:
Bug Depends On: 1950714, 2013597    
Bug Blocks:    

Description Petr Menšík 2021-10-13 10:18:42 UTC
+++ This bug was initially created as a clone of Bug #1950714 +++

Description of problem:

This is a duplicate issue of the https://bugzilla.redhat.com/show_bug.cgi?id=1272835. However, this time is on a RHEL 8.3 server. 

Journal is full of those messages:
=======
SELinux is preventing /usr/sbin/named from name_bind access on the udp_socket port 61000. For complete SELinux messages >
AnalyzeThread.run(): Set alarm timeout to 10
SELinux is preventing /usr/sbin/named from name_bind access on the udp_socket port 61000.

*****  Plugin catchall_boolean (89.3 confidence) suggests   ******************

If you want to allow nis to enabled
Then you must tell SELinux about this by enabling the 'nis_enabled' boolean.

Do
setsebool -P nis_enabled 1

*****  Plugin catchall (11.6 confidence) suggests   **************************

If you believe that named should be allowed name_bind access on the port 61000 udp_socket 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:
# ausearch -c 'named' --raw | audit2allow -M my-named
# semodule -X 300 -i my-named.pp
========

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

selinux-policy-targeted-3.14.3-54.el8_3.3.noarch

How reproducible:
Install named with chroot in a RHEL 8.3 systems

--- Additional comment from Zdenek Pytela on 2021-04-19 20:23:41 CEST ---

Switching the component to bind for the maintainer to assess.

--- Additional comment from Zdenek Pytela on 2021-04-19 20:24:50 CEST ---

Seems to be alike to bz 1830625 which is for unbound, not sure if there also was one for bind.

--- Additional comment from Petr Menšík on 2021-10-12 15:53:06 CEST ---

BIND reads ephemeral values from /proc/sys/net/ipv4/ip_local_port_range file during startup. It should adjust its used range during startup, reported in log.

journalctl -xeu named | grep 'port range'
...named[5001]: using default UDP/IPv4 port range: [32768, 60999]

However, bind-chroot package and named-chroot service do not propagate /proc to chroot, so it cannot read used range from the system. It therefore falls back to defaults, which are blocked by selinux.

journalctl -xeu named-chroot | grep 'port range'
named[5126]: using default UDP/IPv6 port range: [1024, 65535]

It would therefore use also blocked ports by SELinux in this case. I think we do not want whole /proc propagated into chroot for security reasons. But I guess this single file should be propagated there.

Possible workarounds are:
- Not using bind-chroot/named-chroot, but using just named.service. With SELinux enforcing mode it should be well protected even without chroot. chroot is a weak protection compared to SELinux.
- mkdir -p /var/named/chroot/proc/sys/net/ipv4; add /proc/sys/net/ipv4/ip_local_port_range to /etc/named-chroot.files before /var/named
- Add into options section in /etc/named.conf:
        use-v4-udp-ports { range 32768 60999; };
        use-v6-udp-ports { range 32768 60999; };

--- Additional comment from Zdenek Pytela on 2021-10-12 18:32:02 CEST ---

(In reply to Petr Menšík from comment #3)
> Possible workarounds are:
> - Not using bind-chroot/named-chroot, but using just named.service. With
> SELinux enforcing mode it should be well protected even without chroot.
> chroot is a weak protection compared to SELinux.
Personally, I'd not stop using chroot, especially for the cases where customers decide not to use SELinux protection. Also note SELinux can be put into permissive mode temporarily.

> - mkdir -p /var/named/chroot/proc/sys/net/ipv4; add
> /proc/sys/net/ipv4/ip_local_port_range to /etc/named-chroot.files before
> /var/named
> - Add into options section in /etc/named.conf:
>         use-v4-udp-ports { range 32768 60999; };
>         use-v6-udp-ports { range 32768 60999; };

Comment 13 errata-xmlrpc 2022-05-17 13:24:10 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: bind), 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:2502