From: Wojtek Wasko <wwasko@nvidia.com>
To: netdev@vger.kernel.org
Cc: richardcochran@gmail.com, vadim.fedorenko@linux.dev,
kuba@kernel.org, horms@kernel.org, anna-maria@linutronix.de,
frederic@kernel.org, pabeni@redhat.com, tglx@linutronix.de
Subject: [PATCH net-next v4 0/3] Permission checks for dynamic POSIX clocks
Date: Mon, 3 Mar 2025 18:13:42 +0200 [thread overview]
Message-ID: <20250303161345.3053496-1-wwasko@nvidia.com> (raw)
Dynamic clocks - such as PTP clocks - extend beyond the standard POSIX
clock API by using ioctl calls. While file permissions are enforced for
standard POSIX operations, they are not implemented for ioctl calls,
since the POSIX layer cannot differentiate between calls which modify
the clock's state (like enabling PPS output generation) and those that
don't (such as retrieving the clock's PPS capabilities).
On the other hand, drivers implementing the dynamic clocks lack the
necessary information context to enforce permission checks themselves.
Additionally, POSIX clock layer requires the WRITE permission even for
readonly adjtime() operations before invoking the callback.
Add a struct file pointer to the POSIX clock context and use it to
implement the appropriate permission checks on PTP chardevs. Permit
readonly adjtime() for dynamic clocks. Add a readonly option to testptp.
Changes in v4:
- Allow readonly adjtime() for dynamic clocks, as suggested by Thomas
Changes in v3:
- Reword the log message for commit against posix-clock and fix
documentation of struct posix_clock_context, as suggested by Thomas
Changes in v2:
- Store file pointer in POSIX clock context rather than fmode in the PTP
clock's private data, as suggested by Richard.
- Move testptp.c changes into separate patch.
Wojtek Wasko (3):
posix-clock: Store file pointer in struct posix_clock_context
ptp: Add PHC file mode checks. Allow RO adjtime() without FMODE_WRITE.
testptp: Add option to open PHC in readonly mode
drivers/ptp/ptp_chardev.c | 16 ++++++++++++
include/linux/posix-clock.h | 6 ++++-
kernel/time/posix-clock.c | 3 ++-
tools/testing/selftests/ptp/testptp.c | 37 +++++++++++++++++----------
4 files changed, 46 insertions(+), 16 deletions(-)
--
2.43.5
next reply other threads:[~2025-03-03 16:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 16:13 Wojtek Wasko [this message]
2025-03-03 16:13 ` [PATCH net-next v4 1/3] posix-clock: Store file pointer in struct posix_clock_context Wojtek Wasko
2025-03-03 16:13 ` [PATCH net-next v4 2/3] ptp: Add PHC file mode checks. Allow RO adjtime() without FMODE_WRITE Wojtek Wasko
2025-03-03 19:33 ` Thomas Gleixner
2025-03-03 16:13 ` [PATCH net-next v4 3/3] testptp: Add option to open PHC in readonly mode Wojtek Wasko
2025-03-05 12:50 ` [PATCH net-next v4 0/3] Permission checks for dynamic POSIX clocks patchwork-bot+netdevbpf
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=20250303161345.3053496-1-wwasko@nvidia.com \
--to=wwasko@nvidia.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=tglx@linutronix.de \
--cc=vadim.fedorenko@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).