[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8a4335c5-8761-421f-9133-1805df606a90@linux.dev>
Date: Thu, 6 Feb 2025 22:23:28 +0000
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: Wojtek Wasko <wwasko@...dia.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Cc: Richard Cochran <richardcochran@...il.com>,
"kuba@...nel.org" <kuba@...nel.org>, "horms@...nel.org" <horms@...nel.org>
Subject: Re: [PATCH net-next] ptp: Add file permission checks on PHC
On 06/02/2025 11:03, 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].
>
> This patch adds permission checks for functions that modify the state of
> a PTP device. POSIX clock operations (settime, adjtime) continue to be
> checked 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.
>
> [1] https://lists.nwtime.org/sympa/arc/linuxptp-users/2024-01/msg00036.html
>
> Signed-off-by: Wojtek Wasko <wwasko@...dia.com>
> ---
> drivers/ptp/ptp_chardev.c | 52 ++++++++++++++++++++-------
> drivers/ptp/ptp_private.h | 5 +++
> tools/testing/selftests/ptp/testptp.c | 37 +++++++++++--------
> 3 files changed, 67 insertions(+), 27 deletions(-)
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Powered by blists - more mailing lists