Public bug reported:
## Summary
linuxptp 4.4-0ubuntu1 ships three new AppArmor profiles
(debian/usr.sbin.ptp4l, debian/usr.sbin.phc2sys,
debian/usr.sbin.timemaster, added for LP: #2083458). They are written
around the timemaster deployment only and break several documented and
common linuxptp configurations. On a system upgraded from 24.04 to 26.04
the whole PTP -> chrony time chain dies, without any error message
pointing at AppArmor.
Four defects, each independently reproducible:
1. usr.sbin.phc2sys does not allow ptp4l's default UDS /var/run/ptp4l,
although phc2sys -a (automatic mode) connects to exactly that socket.
phc2sys then waits forever and prints "Waiting for ptp4l...".
2. usr.sbin.phc2sys does not allow /var/run/refclock.ptp.sock, where
phc2sys -E refclock_sock writes the samples that chrony reads through
its "refclock SOCK" directive - even though the ptp4l profile does
allow this same path.
3. usr.sbin.ptp4l does not allow /var/run/pmc.<pid>, so ptp4l cannot
answer pmc clients. Every "pmc -u ..." invocation silently returns
nothing, and no AppArmor DENIED record is logged.
4. usr.sbin.ptp4l only allows configuration files below /etc/linuxptp,
so an existing /etc/ptp4l.conf is rejected: ptp4l exits with
"failed to open configuration file /etc/ptp4l.conf: Permission
denied", systemd restarts it, and it crash-loops.
Additionally usr.sbin.phc2sys ends with
"include if exists <local/usr.sbin.ptp4l>" (copy/paste error; should be
local/usr.sbin.phc2sys), which makes site-specific phc2sys overrides
ineffective and applies ptp4l overrides to phc2sys instead.
## Affected versions
* Package: linuxptp 4.4-0ubuntu1 (resolute/26.04, also published for
stonking and tenacious)
* AppArmor parser: 5.0.2 (Ubuntu 26.04)
## Impact
On a host that provides time to a network (PTP slave of a GNSS grand
master, PHC exported to chrony over the SOCK reference clock):
* ptp4l crash-loops (defect 4) or, after moving the configuration to
/etc/linuxptp/, starts but never lets phc2sys subscribe (defect 1).
* phc2sys never writes /var/run/refclock.ptp.sock (defect 2), so chrony
silently falls back to public NTP servers and drops from stratum 1 to
stratum 3.
* "pmc -u -b 0 'GET PORT_DATA_SET'" returns nothing (defect 3), so all
monitoring and watchdog tooling that queries port state is blind.
## Reproduction
Observed on an Ubuntu 26.04 host that was upgraded from 24.04, running
ptp4l -f /etc/ptp4l.conf, phc2sys -a -r -E refclock_sock -m -u256 and
chrony with "refclock SOCK /var/run/refclock.ptp.sock":
# 1) ptp4l crash-loops (configuration path not allowed)
$ journalctl -u ptp4l -n1
ptp4l[..]: failed to open configuration file /etc/ptp4l.conf: Permission
denied
$ systemctl show -p NRestarts --value ptp4l
5446
# 2) phc2sys never talks to ptp4l, although ptp4l is running and SLAVE
$ journalctl -u phc2sys -n3
phc2sys[..]: Waiting for ptp4l...
phc2sys[..]: Waiting for ptp4l...
phc2sys[..]: Waiting for ptp4l...
# 3) pmc gets no answer, and nothing is audited
$ sudo pmc -u -b 0 "GET PORT_DATA_SET"
sending: GET PORT_DATA_SET
# ...and nothing comes back
$ sudo pmc -u -i /var/run/phc2sys.99999 "GET PORT_DATA_SET"
# works, because @{run}/phc2sys.* is allowed in the ptp4l profile
# 4) after moving the configuration file (so ptp4l starts), chrony
# still never sees the BDS refclock: it remains unreachable with
# reach 000 and chrony falls back to a public NTP server.
The profile rules that cause (2), (3) and step 4 were confirmed by
inspecting the shipped profiles; the corresponding sockets/paths are
simply not listed:
* usr.sbin.phc2sys lists @{run}/ptp4lro but not @{run}/ptp4l
* usr.sbin.phc2sys has no @{run}/refclock.ptp.sock rule at all
* usr.sbin.ptp4l has no @{run}/pmc.* rule at all
## Root cause
linuxptp 4.4 config.c defaults uds_address to /var/run/ptp4l; phc2sys -a
connects to it and binds /var/run/phc2sys.<pid>.<n> (phc2sys.c), pmc
binds /var/run/pmc.<pid> (pmc.c). debian/usr.sbin.phc2sys allows only
/var/run/ptp4lro, /var/run/phc2sys.[0-9]*, /dev/ptp*, /dev/pps* and the
timemaster socket; debian/usr.sbin.ptp4l allows /var/run/ptp4l,
/var/run/ptp4lro, /var/run/refclock.ptp.sock, /var/run/phc2sys.* but not
/var/run/pmc.*, and its configuration rule is restricted to
@{etc_ro}/linuxptp/**.
The asymmetry between the two profiles (ptp4l allows
refclock.ptp.sock, phc2sys does not; phc2sys is expected to talk to
ptp4l but the profile only lists the read-only monitoring socket)
indicates the profiles were not tested with phc2sys -a plus a chrony
SOCK refclock.
## Proposed fix
Attached diff (three commits) against ubuntu/devel:
* debian/usr.sbin.phc2sys: add @{run}/ptp4l rw and
@{run}/refclock.ptp.sock rw, fix the local include path.
* debian/usr.sbin.ptp4l: add @{run}/pmc.* rw, drop the
@{run}/run/ptp4l typo and the duplicated ptp4lro line.
* debian/usr.sbin.ptp4l: allow the legacy @{etc_ro}/ptp4l.conf r path
(can be dropped once /etc/linuxptp is the only documented location).
Both files still compile cleanly with apparmor_parser 5.0.2
("apparmor_parser --skip-kernel-load -d <file>").
## Workaround for affected users
sudo tee /etc/apparmor.d/local/usr.sbin.ptp4l >/dev/null <<'EOF'
@{run}/ptp4l rw,
@{run}/pmc.* rw,
@{run}/refclock.ptp.sock rw,
@{etc_ro}/ptp4l.conf r,
EOF
sudo touch /etc/apparmor.d/local/usr.sbin.phc2sys
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.ptp4l
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.phc2sys
sudo systemctl restart ptp4l
(Because of the include error, rules in local/usr.sbin.ptp4l currently
apply to both profiles; writing local/usr.sbin.phc2sys as well keeps the
workaround valid after the include is fixed.)
## Why this should go into 26.04 as an SRU
This is a regression introduced by the 4.4-0ubuntu1 upload. It breaks
upgrades (no user action, no configuration change, just an upgrade), it
silently degrades a time server from stratum 1 to stratum 3, and the fix
is four permission rules confined to AppArmor profiles with no code
change. Risk of regression is minimal.
** Affects: linuxptp (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175143
Title:
linuxptp: AppArmor profiles break phc2sys -a, -E refclock_sock, pmc
queries and the legacy /etc/ptp4l.conf path
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linuxptp/+bug/2175143/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs