Re: [PATCH] ptp: Limit time setting of PTP clocks
From: Miroslav Lichvar
Date: Tue Sep 10 2024 - 08:01:55 EST
On Mon, Sep 09, 2024 at 08:48:24AM -0700, Richard Cochran wrote:
> > diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> > index c56cd0f63909..bd7c5f534be6 100644
> > --- a/drivers/ptp/ptp_clock.c
> > +++ b/drivers/ptp/ptp_clock.c
> > @@ -100,6 +100,9 @@ static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 *tp
> > return -EBUSY;
> > }
> >
> > + if (!timespec64_valid_settod(tp))
> > + return -EINVAL;
>
> Why not perform the test earlier, in SYSCALL_DEFINE2(clock_settime, ...) ?
It would be more code as there are also the 32-bit compat variants of
the functions. The adjtime function would probably need to handle
missing gettime.
The limit would apply to all clocks, not just PTP clocks. If nothing
else, I suspect it would change returned errors for other clocks
trying to set the an unacceptable timespec value.
--
Miroslav Lichvar