All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 14/22] time:Introduce the do_sys_settimeofday64() function with timespec64 type
@ 2015-05-11 11:19 Baolin Wang
  2015-05-12 15:17 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2015-05-11 11:19 UTC (permalink / raw)
  To: tglx
  Cc: arnd, john.stultz, heenasirwani, pang.xunlei, linux-kernel,
	baolin.wang, y2038

This patch introduces the do_sys_settimeofday64() function with timespec64
type, that makes this function ready for 2038 issue when setting the time of day.
And moves the do_sys_settimeofday() function to the timekeeping.h file.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/timekeeping.h |   12 ++++++++++--
 kernel/time/time.c          |   10 ++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index c6d5ae9..89beb62 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -11,8 +11,16 @@ extern int timekeeping_suspended;
  */
 extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
-extern int do_sys_settimeofday(const struct timespec *tv,
-			       const struct timezone *tz);
+extern int do_sys_settimeofday64(const struct timespec64 *tv,
+				 const struct timezone *tz);
+static inline int do_sys_settimeofday(const struct timespec *tv,
+				      const struct timezone *tz)
+{
+	struct timespec64 ts64;
+
+	ts64 = timespec_to_timespec64(*tv);
+	return do_sys_settimeofday64(&ts64, tz);
+}
 
 /*
  * Kernel time accessors
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 2c85b77..f43011b 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -160,15 +160,17 @@ static inline void warp_clock(void)
  * various programs will get confused when the clock gets warped.
  */
 
-int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
+int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz)
 {
 	static int firsttime = 1;
 	int error = 0;
+	struct timespec ts;
 
-	if (tv && !timespec_valid(tv))
+	if (tv && !timespec64_valid(tv))
 		return -EINVAL;
 
-	error = security_settime(tv, tz);
+	ts = timespec64_to_timespec(*tv);
+	error = security_settime(&ts, tz);
 	if (error)
 		return error;
 
@@ -182,7 +184,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
 		}
 	}
 	if (tv)
-		return do_settimeofday(tv);
+		return do_settimeofday64(tv);
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 14/22] time:Introduce the do_sys_settimeofday64() function with timespec64 type
  2015-05-11 11:19 [PATCH v3 14/22] time:Introduce the do_sys_settimeofday64() function with timespec64 type Baolin Wang
@ 2015-05-12 15:17 ` Thomas Gleixner
       [not found]   ` <CAMz4kuKY3fu6B-36OGQKnAr-r8LcCrO-NhTDYzBdYF6JPiKyFg@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2015-05-12 15:17 UTC (permalink / raw)
  To: Baolin Wang
  Cc: arnd, john.stultz, heenasirwani, pang.xunlei, linux-kernel, y2038

On Mon, 11 May 2015, Baolin Wang wrote:

> This patch introduces the do_sys_settimeofday64() function with timespec64
> type, that makes this function ready for 2038 issue when setting the time of day.

Copy and paste is your favourite work method, right?

> -int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
> +int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz)
>  {
>  	static int firsttime = 1;
>  	int error = 0;
> +	struct timespec ts;
>  
> -	if (tv && !timespec_valid(tv))
> +	if (tv && !timespec64_valid(tv))
>  		return -EINVAL;
>  
> -	error = security_settime(tv, tz);
> +	ts = timespec64_to_timespec(*tv);
> +	error = security_settime(&ts, tz);

How is that 2038 safe? Not at all.

I told you before that we fix the underlying functions before we add
such bogosities.

Thanks,

	tglx


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Y2038] [PATCH v3 14/22] time:Introduce the do_sys_settimeofday64() function with timespec64 type
       [not found]   ` <CAMz4kuKY3fu6B-36OGQKnAr-r8LcCrO-NhTDYzBdYF6JPiKyFg@mail.gmail.com>
@ 2015-05-13  7:55     ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2015-05-13  7:55 UTC (permalink / raw)
  To: y2038
  Cc: Baolin Wang, Thomas Gleixner, Xunlei Pang, linux-kernel,
	John Stultz, Heena Sirwani

On Wednesday 13 May 2015 10:43:25 Baolin Wang wrote:
> > > -int do_sys_settimeofday(const struct timespec *tv, const struct
> > timezone *tz)
> > > +int do_sys_settimeofday64(const struct timespec64 *tv, const struct
> > timezone *tz)
> > >  {
> > >       static int firsttime = 1;
> > >       int error = 0;
> > > +     struct timespec ts;
> > >
> > > -     if (tv && !timespec_valid(tv))
> > > +     if (tv && !timespec64_valid(tv))
> > >               return -EINVAL;
> > >
> > > -     error = security_settime(tv, tz);
> > > +     ts = timespec64_to_timespec(*tv);
> > > +     error = security_settime(&ts, tz);
> >
> > How is that 2038 safe? Not at all.
> >
> > I told you before that we fix the underlying functions before we add
> > such bogosities.
> >
> >
> Thanks for your comments, and i'll continue to repair my patch.
> But could you explain what the defects in do_sys_settimeofday64
> function? Thanks.

What Thomas meant here is that you should first fix security_settime
to take a timespec64 argument. I guess you could introduce a
security_settime64() function first, using another inline wrapper
to provide the existing security_settime() API. security_settime()
does not actually use the time argument, so this is a fairly easy
thing to do.

	Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-13  7:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11 11:19 [PATCH v3 14/22] time:Introduce the do_sys_settimeofday64() function with timespec64 type Baolin Wang
2015-05-12 15:17 ` Thomas Gleixner
     [not found]   ` <CAMz4kuKY3fu6B-36OGQKnAr-r8LcCrO-NhTDYzBdYF6JPiKyFg@mail.gmail.com>
2015-05-13  7:55     ` [Y2038] " Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.