Re: [PATCH net-next v3 2/3] ptp: Add file permission checks on PHCs
From: Thomas Gleixner <hidden>
Date: 2025-02-17 20:24:25
On Mon, Feb 17 2025 at 11:50, Wojtek Wasko wrote:
Many devices implement highly accurate clocks, which the kernel manages as PTP Hardware Clocks (PHCs). Userspace applications rely on these clocks to timestamp events, trace workload execution, correlate timescales across devices, and keep various clocks in sync. The kernel’s current implementation of PTP clocks does not enforce file permissions checks for most device operations except for POSIX clock operations, where file mode is verified in the POSIX layer before forwarding the call to the PTP subsystem. Consequently, it is common practice to not give unprivileged userspace applications any access to PTP clocks whatsoever by giving the PTP chardevs 600 permissions. An example of users running into this limitation is documented in [1]. Add permission checks for functions that modify the state of a PTP device. Continue enforcing permission checks for POSIX clock operations (settime, adjtime) in the POSIX layer. One limitation remains: querying the adjusted frequency of a PTP device (using adjtime() with an empty modes field) is not supported for chardevs opened without WRITE permissions, as the POSIX layer mandates WRITE access for any adjtime operation.
That's a fixable problem, no?