From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Wojtek Wasko <wwasko@nvidia.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"horms@kernel.org" <horms@kernel.org>
Subject: Re: [PATCH net-next] ptp: Add file permission checks on PHC
Date: Thu, 6 Feb 2025 22:23:28 +0000 [thread overview]
Message-ID: <8a4335c5-8761-421f-9133-1805df606a90@linux.dev> (raw)
In-Reply-To: <DM4PR12MB8558CE01707ED1DD3305A9FCBEF62@DM4PR12MB8558.namprd12.prod.outlook.com>
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@nvidia.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@linux.dev>
next prev parent reply other threads:[~2025-02-06 22:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 11:03 [PATCH net-next] ptp: Add file permission checks on PHC Wojtek Wasko
2025-02-06 22:23 ` Vadim Fedorenko [this message]
2025-02-07 15:26 ` Richard Cochran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a4335c5-8761-421f-9133-1805df606a90@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=wwasko@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.