Bug 2118631

Summary: [RHEL9] chronyd not allowed to bind to PTP event port
Product: Red Hat Enterprise Linux 9 Reporter: Miroslav Lichvar <mlichvar>
Component: selinux-policyAssignee: Nikola Knazekova <nknazeko>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: low    
Version: 9.1CC: lvrabec, mmalik, nknazeko, ssekidde
Target Milestone: rcKeywords: Triaged
Target Release: 9.1Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-34.1.41-1.el9 Doc Type: Bug Fix
Doc Text:
Cause: selinux policy prevents chronyd from binding to the PTP socket 319. Consequence: chronyd cannot get access to timestamping PTP event messages containing NTP messages. Fix: Label port 319/udp with ptp_event_port_t and allow chronyd bind UDP sockets to ptp_event ports. Result: No AVC denials
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 11:14:11 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 Miroslav Lichvar 2022-08-16 10:08:43 UTC
This bug was initially created as a copy of Bug #2118628

I am copying this bug because: 
The same issue is observed on RHEL9 with the following packages:
selinux-policy-34.1.34-1.el9.noarch
chrony-4.2-1.el9.x86_64


Description of problem:
As a new feature added in chrony-4.2, chronyd supports an experimental NTP-over-PTP protocol in order to get HW timestamps on NICs which can timestamp PTP packets but not NTP packets.

The selinux policy seems to be preventing chronyd from binding to the PTP socket 319.

In system log:
Aug 16 11:56:33 rhel8 chronyd[974]: Could not open NTP socket on 0.0.0.0:319
Aug 16 11:56:33 rhel8 chronyd[974]: Could not open NTP socket on [::]:319

In audit log:
type=AVC msg=audit(1660643793.324:174): avc:  denied  { name_bind } for  pid=974 comm="chronyd" src=319 scontext=system_u:system_r:chronyd_t:s0 tcontext=system_u:object_r:reserved_port_t:s0 tclass=udp_socket permissive=0

With disabled enforcing there are no other messages.

Version-Release number of selected component (if applicable):
selinux-policy-3.14.3-106.el8.noarch
chrony-4.2-1.el8.x86_64

How reproducible:
always

Steps to Reproduce:
1. cat <<EOF >> /etc/chrony.conf
allow
ptpport 319
server 127.0.0.1 port 319 minpoll 0 maxpoll 0
EOF
2. systemctl restart chronyd
3. wait 5 seconds
4. chronyc ntpdata 127.0.0.1 | grep 'Total RX'

Actual results:
0

Expected results:
> 0

Additional info:

Comment 16 errata-xmlrpc 2022-11-15 11:14:11 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 (selinux-policy 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/RHBA-2022:8283