Thread (9 messages) 9 messages, 2 authors, 2025-02-20

RE: [PATCH net-next v3 2/3] ptp: Add file permission checks on PHCs

From: Thomas Gleixner <hidden>
Date: 2025-02-20 12:53:02

On Wed, Feb 19 2025 at 09:45, Wojtek Wasko wrote:
On Mon, Feb 17 2025 at 21:24, Thomas Gleixner wrote:
quoted
quoted
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?
Absolutely, but to be honest I wasn't sure about how to properly change
the access check in adjtime given it's a "generic" API. I ended up with
something along the lines of:

   if (tx->modes & ~(ADJ_NANO | ADJ_MICRO))
     /* require WRITE */

being that ADJ_NANO and ADJ_MICRO by themselves don't mean the clock will
be modified. So the modes field is not really "empty" per se and the check
becomes less self-explanatory.
ADJ_NANO and ADJ_MICRO modify the internal status. A read only operation
has to have tx->modes == 0 and the result will be served in the
NANO/MICRO representation which was set by the control application which
can write.

adjtimex(2) is clearly saying:

 "The modes field determines which parameters, if any, to set."

Consequently modes != 0 requires CAP_SYS_TIME, while modes == 0 is
unpriviledged. So requiring WRITE for the FD based posix clocks is not
asked too much.

Thanks,

        tglx
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help