Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1603905

[RESEND PATCH 1/7] time: Delete do_sys_setimeofday()

From Deepa Dinamani <deepa.kernel@gmail.com>
Newsgroups linux.kernel
Subject [RESEND PATCH 1/7] time: Delete do_sys_setimeofday()
Date 2017-03-19 06:30 +0100
Message-ID <tmBzH-XZ-7@gated-at.bofh.it> (permalink)
References <tmBzH-XZ-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces will be changed in a separate
series.
Call to do_sys_setimeofday() is superfluous as all
the necessary checks and functions are done by the
underlying function do_sys_setimeofday64().
Replace do_sys_setimeofday64() directly instead of
do_sys_settimeofday(). The do_sys_setimeofday64()
calls timespec64_valid() internally, which is the
same as timespec_valid().

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
 include/linux/timekeeping.h | 15 ---------------
 kernel/compat.c             |  4 ++--
 kernel/time/posix-stubs.c   |  5 ++++-
 kernel/time/posix-timers.c  |  5 ++++-
 kernel/time/time.c          |  4 ++--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index b598cbc..3617a78 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 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;
-
-	if (!tv)
-		return do_sys_settimeofday64(NULL, tz);
-
-	if (!timespec_valid(tv))
-		return -EINVAL;
-
-	ts64 = timespec_to_timespec64(*tv);
-	return do_sys_settimeofday64(&ts64, tz);
-}
-
 /*
  * Kernel time accessors
  */
diff --git a/kernel/compat.c b/kernel/compat.c
index 19aec5d..e29a01a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -109,7 +109,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
 		       struct timezone __user *, tz)
 {
 	struct timeval user_tv;
-	struct timespec	new_ts;
+	struct timespec64 new_ts;
 	struct timezone new_tz;
 
 	if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
 			return -EFAULT;
 	}
 
-	return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
+	return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
 }
 
 static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index cd6716e..df275db 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -50,12 +50,15 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
 		const struct timespec __user *, tp)
 {
 	struct timespec new_tp;
+	struct timespec64 new_tp64;
 
 	if (which_clock != CLOCK_REALTIME)
 		return -EINVAL;
 	if (copy_from_user(&new_tp, tp, sizeof (*tp)))
 		return -EFAULT;
-	return do_sys_settimeofday(&new_tp, NULL);
+
+	new_tp64 = timespec_to_timespec64(new_tp);
+	return do_sys_settimeofday64(&new_tp64, NULL);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 50a6a47..f215ef7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, struct timespec *tp)
 static int posix_clock_realtime_set(const clockid_t which_clock,
 				    const struct timespec *tp)
 {
-	return do_sys_settimeofday(tp, NULL);
+	struct timespec64 tp64;
+
+	tp64 = timespec_to_timespec64(*tp);
+	return do_sys_settimeofday64(&tp64, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..450e8a1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -194,7 +194,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
 		struct timezone __user *, tz)
 {
 	struct timeval user_tv;
-	struct timespec	new_ts;
+	struct timespec64 new_ts;
 	struct timezone new_tz;
 
 	if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
 			return -EFAULT;
 	}
 
-	return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
+	return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
 }
 
 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RESEND PATCH 0/7] Change k_clock interfaces to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
  [RESEND PATCH 1/7] time: Delete do_sys_setimeofday() Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
    Re: [RESEND PATCH 1/7] time: Delete do_sys_setimeofday() Thomas Gleixner <tglx@linutronix.de> - 2017-03-19 12:00 +0100
    Re: [RESEND PATCH 1/7] time: Delete do_sys_setimeofday() kbuild test robot <lkp@intel.com> - 2017-03-21 18:30 +0100
      Re: [RESEND PATCH 1/7] time: Delete do_sys_setimeofday() Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-21 20:00 +0100
  [RESEND PATCH 3/7] Change k_clock clock_get() to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
    Re: [RESEND PATCH 3/7] Change k_clock clock_get() to use  timespec64 Thomas Gleixner <tglx@linutronix.de> - 2017-03-19 12:10 +0100
  [RESEND PATCH 5/7] Change k_clock clock_set() to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
  [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
    Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Thomas Gleixner <tglx@linutronix.de> - 2017-03-19 12:00 +0100
      Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-20 21:40 +0100
        Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Thomas Gleixner <tglx@linutronix.de> - 2017-03-20 21:50 +0100
          Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Arnd Bergmann <arnd@arndb.de> - 2017-03-21 09:20 +0100
            Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Thomas Gleixner <tglx@linutronix.de> - 2017-03-21 10:10 +0100
      Re: [Y2038] [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64 Tomoyoshi ASANO <asa@lineo.co.jp> - 2017-03-20 23:50 +0100
    Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Richard Cochran <richardcochran@gmail.com> - 2017-03-19 19:10 +0100
      Re: [RESEND PATCH 2/7] time: Change posix clocks ops interfaces to  use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-20 21:40 +0100
  [RESEND PATCH 7/7] Change k_clock nsleep() to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
  [RESEND PATCH 6/7] Change k_clock timer_set() and timer_get() to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-19 06:30 +0100
  Re: [RESEND PATCH 0/7] Change k_clock interfaces to use timespec64 Thomas Gleixner <tglx@linutronix.de> - 2017-03-19 12:10 +0100
    Re: [RESEND PATCH 0/7] Change k_clock interfaces to use timespec64 Deepa Dinamani <deepa.kernel@gmail.com> - 2017-03-20 21:40 +0100

csiph-web