Re: [Y2038] [PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-21 Thread Deepa Dinamani
>> index f608941..97a883a 100644
>> --- a/include/linux/posix-timers.h
>> +++ b/include/linux/posix-timers.h
>> @@ -94,7 +94,7 @@ struct k_clock {
>> int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
>> int (*timer_create) (struct k_itimer *timer);
>> int (*nsleep) (const clockid_t which_clock, int flags,
>> -  struct timespec *, struct timespec __user *);
>> +  struct timespec64 *, struct timespec __user *);
>> long (*nsleep_restart) (struct restart_block *restart_block);
>
> You change one of the two arguments, but not the second one
> or the code in the restart handler that uses that __user pointer.
>
> Your patch is a good step in the right direction, and the second half
> of it is definitely complicated enough to be done in a separate
> patch, so I think it's good to keep them separate, just add
> explain why this is done one at a time.

Yes, this is intentional.
I was including the restart_block param in the syscall interfaces category.

I will make an explicit note in the commit text.

Thanks,
Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-21 Thread Arnd Bergmann
On Sun, Mar 19, 2017 at 4:57 AM, Deepa Dinamani  wrote:
> From: Deepa Dinamani 
>
> 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 themselves will be changed
> in a separate series.
>
> Signed-off-by: Deepa Dinamani 

It's worth pointing out here that this patch only does half the job:

> index f608941..97a883a 100644
> --- a/include/linux/posix-timers.h
> +++ b/include/linux/posix-timers.h
> @@ -94,7 +94,7 @@ struct k_clock {
> int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
> int (*timer_create) (struct k_itimer *timer);
> int (*nsleep) (const clockid_t which_clock, int flags,
> -  struct timespec *, struct timespec __user *);
> +  struct timespec64 *, struct timespec __user *);
> long (*nsleep_restart) (struct restart_block *restart_block);

You change one of the two arguments, but not the second one
or the code in the restart handler that uses that __user pointer.

Your patch is a good step in the right direction, and the second half
of it is definitely complicated enough to be done in a separate
patch, so I think it's good to keep them separate, just add
explain why this is done one at a time.

Arnd
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-18 Thread Deepa Dinamani
From: Deepa Dinamani 

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 themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/compat.c|  6 --
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/hrtimer.c  | 10 ++
 kernel/time/posix-cpu-timers.c | 36 ++--
 kernel/time/posix-stubs.c  |  6 --
 kernel/time/posix-timers.c | 10 ++
 8 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 249e579..7d019c0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -456,7 +456,7 @@ static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 }
 
 /* Precise sleep: */
-extern long hrtimer_nanosleep(struct timespec *rqtp,
+extern long hrtimer_nanosleep(struct timespec64 *rqtp,
  struct timespec __user *rmtp,
  const enum hrtimer_mode mode,
  const clockid_t clockid);
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f608941..97a883a 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -94,7 +94,7 @@ struct k_clock {
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
-  struct timespec *, struct timespec __user *);
+  struct timespec64 *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec64 * new_setting,
diff --git a/kernel/compat.c b/kernel/compat.c
index e29a01a..8ec15d1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -240,18 +240,20 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec 
__user *, rqtp,
   struct compat_timespec __user *, rmtp)
 {
struct timespec tu, rmt;
+   struct timespec64 tu64;
mm_segment_t oldfs;
long ret;
 
if (compat_get_timespec(&tu, rqtp))
return -EFAULT;
 
-   if (!timespec_valid(&tu))
+   tu64 = timespec_to_timespec64(tu);
+   if (!timespec64_valid(&tu64))
return -EINVAL;
 
oldfs = get_fs();
set_fs(KERNEL_DS);
-   ret = hrtimer_nanosleep(&tu,
+   ret = hrtimer_nanosleep(&tu64,
rmtp ? (struct timespec __user *)&rmt : NULL,
HRTIMER_MODE_REL, CLOCK_MONOTONIC);
set_fs(oldfs);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 81db6df..cc20417 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -790,7 +790,7 @@ static long __sched alarm_timer_nsleep_restart(struct 
restart_block *restart)
  * Handles clock_nanosleep calls against _ALARM clockids
  */
 static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
-struct timespec *tsreq, struct timespec __user *rmtp)
+struct timespec64 *tsreq, struct timespec __user *rmtp)
 {
enum  alarmtimer_type type = clock2alarm(which_clock);
struct alarm alarm;
@@ -809,7 +809,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, 
int flags,
 
alarm_init(&alarm, type, alarmtimer_nsleep_wakeup);
 
-   exp = timespec_to_ktime(*tsreq);
+   exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime();
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ec08f52..f530295 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1506,7 +1506,7 @@ long __sched hrtimer_nanosleep_restart(struct 
restart_block *restart)
return ret;
 }
 
-long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
+long hrtimer_nanosleep(struct timespec64 *rqtp, struct timespec __user *rmtp,
   const enum hrtimer_mode mode, const clockid_t clockid)
 {
struct restart_block *restart;
@@ -1519,7 +1519,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct 
timespec __user *rmtp,
slack = 0;
 
hrtimer_init_on_stack(&t.timer, clockid, mode);
-   hrtimer_set_expires_range_ns(&t.timer, timespec_to_ktime(*rqtp), slack);
+   hrtimer_set_expires_range_ns(&t.timer, timespec64_to_ktime(*rqtp), 
slack);
if (do_nanosleep(&t, mode))
goto out;
 
@@ -1551,14 +1551,16 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, 
rqtp,
struct ti