Bug 1950714

Summary: SELinux is preventing /usr/sbin/named from 'name_bind' accesses on the udp_socket port 61000.
Product: Red Hat Enterprise Linux 8 Reporter: Peter Tselios <tselios.petros>
Component: bindAssignee: Petr Menšík <pemensik>
Status: CLOSED ERRATA QA Contact: Petr Sklenar <psklenar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.3CC: bnater, lvrabec, mmalik, plautrba, psklenar, ssekidde, zpytela
Target Milestone: betaKeywords: AutoVerified, TestCaseProvided, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: bind-9.11.26-8.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2013595 2013597 (view as bug list) Environment:
Last Closed: 2022-05-10 15:29:44 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:    
Bug Blocks: 2013595, 2013597, 2144069    

Description Peter Tselios 2021-04-18 05:05:19 UTC
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

Comment 1 Zdenek Pytela 2021-04-19 18:23:41 UTC
Switching the component to bind for the maintainer to assess.

Comment 3 Petr Menšík 2021-10-12 13:53:06 UTC
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; };

Comment 4 Zdenek Pytela 2021-10-12 16:32:02 UTC
(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 21 errata-xmlrpc 2022-05-10 15:29:44 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 (Moderate: bind security, bug fix, and enhancement update), 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/RHSA-2022:2092