Re: [PATCH] [v3] y2038: introduce struct __kernel_old_timeval

From: Thomas Gleixner
Date: Fri Mar 16 2018 - 06:12:10 EST


On Fri, 16 Mar 2018, Arnd Bergmann wrote:
> On Fri, Mar 16, 2018 at 1:02 AM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> > On Thu, 15 Mar 2018, Arnd Bergmann wrote:
> >> + * legacy timeval structure, only embedded in structures that
> >> + * traditionally used 'timeval' to pass time intervals (not absolute
> >> + * times). Do not add new users. If user space fails to compile
> >> + * here, this is probably because it is not y2038 safe and needs to
> >> + * be changed to use another interface.
> >> + */
> >> +struct __kernel_old_timeval {
> >> + __kernel_long_t tv_sec;
> >> + __kernel_long_t tv_usec;
> >> +};
> >> +
> >> +/*
> >> * The IDs of the various system clocks (for POSIX.1b interval timers):
> >> */
> >> #define CLOCK_REALTIME 0
> >> diff --git a/kernel/time/time.c b/kernel/time/time.c
> >> index 5db8f15ec056..6fa99213fc72 100644
> >> --- a/kernel/time/time.c
> >> +++ b/kernel/time/time.c
> >> @@ -486,6 +486,18 @@ struct timeval ns_to_timeval(const s64 nsec)
> >> }
> >> EXPORT_SYMBOL(ns_to_timeval);
> >>
> >> +struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64 nsec)
> >> +{
> >> + struct timespec64 ts = ns_to_timespec64(nsec);
> >> + struct __kernel_old_timeval tv;
> >> +
> >> + tv.tv_sec = ts.tv_sec;
> >
> > We might think about adding some debug aid here which yells when ts.tv_sec
> > is > than the cutoff.
> >
> > Hmm?
>
> We discussed those before (a long time ago) and couldn't really
> reach consensus. If we do that, I'd like to have it done consistently
> across the kernel, and in a separate patch series.

Sure.

> In particular, we need to decide on a policy for how to handle
> it depending on the caller, e.g. do we want to have a way to
> WARN_ONCE() for any process calling an unsafe function even
> if it doesn't overflow, should we try to return an error to a syscall
> when it does overflow, should the behavior be configurable etc.

Yeah. Needs some thought.

I didn't mean that we need this now, but in the long run some form of debug
aid might be required.

Thanks,

tglx