From: Simon Horman <horms@kernel.org>
To: Wojtek Wasko <wwasko@nvidia.com>
Cc: netdev@vger.kernel.org, Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH RFC net-next] ptp: Add file permission checks on PHC chardevs
Date: Sat, 1 Feb 2025 16:02:37 +0000 [thread overview]
Message-ID: <20250201160237.GB211663@kernel.org> (raw)
In-Reply-To: <DM4PR12MB8558AB3C0DEA666EE334D8BCBEE82@DM4PR12MB8558.namprd12.prod.outlook.com>
On Fri, Jan 31, 2025 at 06:29:23PM +0000, Wojtek Wasko wrote:
> Udev sets strict 600 permissions on /dev/ptp* devices, preventing
> unprivileged users from accessing the time [1]. This patch enables
> more granular permissions and allows readonly access to the PTP clocks.
>
> Add permission checking for ioctls which modify the state of device.
> Notably, require WRITE for polling as it is only used for later reading
> timestamps from the queue (there is no peek support). POSIX clock
> operations (settime, adjtime) are checked in the POSIX layer.
>
> [1] https://lists.nwtime.org/sympa/arc/linuxptp-users/2024-01/msg00036.html
>
> Signed-off-by: Wojtek Wasko <wwasko@nvidia.com>
...
> @@ -516,9 +554,15 @@ __poll_t ptp_poll(struct posix_clock_context *pccontext, struct file *fp,
> {
> struct ptp_clock *ptp =
> container_of(pccontext->clk, struct ptp_clock, clock);
> + struct ptp_private_ctxdata *ctxdata;
> struct timestamp_event_queue *queue;
>
> - queue = pccontext->private_clkdata;
> + ctxdata = pccontext->private_clkdata;
> + if (!ctxdata)
> + return EPOLLERR;
> + if ((ctxdata->fmode & FMODE_WRITE) == 0)
> + return EACCES;
Hi Wojtek,
This is not a full review, but rather, something to take into account
if this idea goes forwards:
The return type of this function is __poll_t, not int.
So I think this should be EPOLLERR rather than EACCESS.
> + queue = ctxdata->queue;
> if (!queue)
> return EPOLLERR;
>
...
next prev parent reply other threads:[~2025-02-01 16:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 18:29 [PATCH RFC net-next] ptp: Add file permission checks on PHC chardevs Wojtek Wasko
2025-02-01 16:02 ` Simon Horman [this message]
2025-02-01 16:22 ` Vadim Fedorenko
2025-02-02 6:24 ` 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=20250201160237.GB211663@kernel.org \
--to=horms@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 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).