All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] posix-stubs: use get_timespec64() and put_timespec64()
@ 2017-10-13 18:29 Arnd Bergmann
  2017-10-13 19:22 ` Nicolas Pitre
  2017-10-17 15:42 ` [tip:timers/core] posix-stubs: Use " tip-bot for Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-10-13 18:29 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: y2038, Arnd Bergmann, Al Viro, Deepa Dinamani, John Stultz,
	Nicolas Pitre, linux-kernel

This is a follow-up to commit 5c4994102fb5 ("posix-timers:
Use get_timespec64() and put_timespec64()"), which left two
system call using copy_from_user()/copy_to_user(). We can
change them as well for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/time/posix-stubs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index 06f34feb635e..b258bee13b02 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -117,8 +117,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
 		const struct timespec __user *, rqtp,
 		struct timespec __user *, rmtp)
 {
-	struct timespec64 t64;
-	struct timespec t;
+	struct timespec64 t;
 
 	switch (which_clock) {
 	case CLOCK_REALTIME:
@@ -129,16 +128,15 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
 		return -EINVAL;
 	}
 
-	if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
+	if (get_timespec64(&t, rqtp))
 		return -EFAULT;
-	t64 = timespec_to_timespec64(t);
-	if (!timespec64_valid(&t64))
+	if (!timespec64_valid(&t))
 		return -EINVAL;
 	if (flags & TIMER_ABSTIME)
 		rmtp = NULL;
 	current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
 	current->restart_block.nanosleep.rmtp = rmtp;
-	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
 				 which_clock);
 }
@@ -203,8 +201,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
 		       struct compat_timespec __user *, rqtp,
 		       struct compat_timespec __user *, rmtp)
 {
-	struct timespec64 t64;
-	struct timespec t;
+	struct timespec64 t;
 
 	switch (which_clock) {
 	case CLOCK_REALTIME:
@@ -215,16 +212,15 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
 		return -EINVAL;
 	}
 
-	if (compat_get_timespec(&t, rqtp))
+	if (compat_get_timespec64(&t, rqtp))
 		return -EFAULT;
-	t64 = timespec_to_timespec64(t);
-	if (!timespec64_valid(&t64))
+	if (!timespec64_valid(&t))
 		return -EINVAL;
 	if (flags & TIMER_ABSTIME)
 		rmtp = NULL;
 	current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
 	current->restart_block.nanosleep.compat_rmtp = rmtp;
-	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
 				 which_clock);
 }
-- 
2.9.0

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

* Re: [PATCH] posix-stubs: use get_timespec64() and put_timespec64()
  2017-10-13 18:29 [PATCH] posix-stubs: use get_timespec64() and put_timespec64() Arnd Bergmann
@ 2017-10-13 19:22 ` Nicolas Pitre
  2017-10-17 15:42 ` [tip:timers/core] posix-stubs: Use " tip-bot for Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2017-10-13 19:22 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Thomas Gleixner, y2038, Al Viro, Deepa Dinamani, John Stultz,
	linux-kernel

On Fri, 13 Oct 2017, Arnd Bergmann wrote:

> This is a follow-up to commit 5c4994102fb5 ("posix-timers:
> Use get_timespec64() and put_timespec64()"), which left two
> system call using copy_from_user()/copy_to_user(). We can
> change them as well for consistency.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Nicolas Pitre <nico@linaro.org>

> ---
>  kernel/time/posix-stubs.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
> index 06f34feb635e..b258bee13b02 100644
> --- a/kernel/time/posix-stubs.c
> +++ b/kernel/time/posix-stubs.c
> @@ -117,8 +117,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
>  		const struct timespec __user *, rqtp,
>  		struct timespec __user *, rmtp)
>  {
> -	struct timespec64 t64;
> -	struct timespec t;
> +	struct timespec64 t;
>  
>  	switch (which_clock) {
>  	case CLOCK_REALTIME:
> @@ -129,16 +128,15 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
>  		return -EINVAL;
>  	}
>  
> -	if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
> +	if (get_timespec64(&t, rqtp))
>  		return -EFAULT;
> -	t64 = timespec_to_timespec64(t);
> -	if (!timespec64_valid(&t64))
> +	if (!timespec64_valid(&t))
>  		return -EINVAL;
>  	if (flags & TIMER_ABSTIME)
>  		rmtp = NULL;
>  	current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
>  	current->restart_block.nanosleep.rmtp = rmtp;
> -	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
> +	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
>  				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
>  				 which_clock);
>  }
> @@ -203,8 +201,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
>  		       struct compat_timespec __user *, rqtp,
>  		       struct compat_timespec __user *, rmtp)
>  {
> -	struct timespec64 t64;
> -	struct timespec t;
> +	struct timespec64 t;
>  
>  	switch (which_clock) {
>  	case CLOCK_REALTIME:
> @@ -215,16 +212,15 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
>  		return -EINVAL;
>  	}
>  
> -	if (compat_get_timespec(&t, rqtp))
> +	if (compat_get_timespec64(&t, rqtp))
>  		return -EFAULT;
> -	t64 = timespec_to_timespec64(t);
> -	if (!timespec64_valid(&t64))
> +	if (!timespec64_valid(&t))
>  		return -EINVAL;
>  	if (flags & TIMER_ABSTIME)
>  		rmtp = NULL;
>  	current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
>  	current->restart_block.nanosleep.compat_rmtp = rmtp;
> -	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
> +	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
>  				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
>  				 which_clock);
>  }
> -- 
> 2.9.0
> 
> 

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

* [tip:timers/core] posix-stubs: Use get_timespec64() and put_timespec64()
  2017-10-13 18:29 [PATCH] posix-stubs: use get_timespec64() and put_timespec64() Arnd Bergmann
  2017-10-13 19:22 ` Nicolas Pitre
@ 2017-10-17 15:42 ` tip-bot for Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Arnd Bergmann @ 2017-10-17 15:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: nicolas.pitre, mingo, john.stultz, arnd, viro, deepa.kernel,
	linux-kernel, hpa, tglx

Commit-ID:  fe460423438b62eb7440d994ab19a9f444e6280d
Gitweb:     https://git.kernel.org/tip/fe460423438b62eb7440d994ab19a9f444e6280d
Author:     Arnd Bergmann <arnd@arndb.de>
AuthorDate: Fri, 13 Oct 2017 20:29:38 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 17 Oct 2017 17:22:27 +0200

posix-stubs: Use get_timespec64() and put_timespec64()

This is a follow-up to commit 5c4994102fb5 ("posix-timers: Use
get_timespec64() and put_timespec64()"), which left two system call using
copy_from_user()/copy_to_user().

Change them as well for consistency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: y2038@lists.linaro.org
Cc: John Stultz <john.stultz@linaro.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Link: https://lkml.kernel.org/r/20171013183009.3442318-1-arnd@arndb.de

---
 kernel/time/posix-stubs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index 06f34fe..b258bee 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -117,8 +117,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
 		const struct timespec __user *, rqtp,
 		struct timespec __user *, rmtp)
 {
-	struct timespec64 t64;
-	struct timespec t;
+	struct timespec64 t;
 
 	switch (which_clock) {
 	case CLOCK_REALTIME:
@@ -129,16 +128,15 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
 		return -EINVAL;
 	}
 
-	if (copy_from_user(&t, rqtp, sizeof (struct timespec)))
+	if (get_timespec64(&t, rqtp))
 		return -EFAULT;
-	t64 = timespec_to_timespec64(t);
-	if (!timespec64_valid(&t64))
+	if (!timespec64_valid(&t))
 		return -EINVAL;
 	if (flags & TIMER_ABSTIME)
 		rmtp = NULL;
 	current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
 	current->restart_block.nanosleep.rmtp = rmtp;
-	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
 				 which_clock);
 }
@@ -203,8 +201,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
 		       struct compat_timespec __user *, rqtp,
 		       struct compat_timespec __user *, rmtp)
 {
-	struct timespec64 t64;
-	struct timespec t;
+	struct timespec64 t;
 
 	switch (which_clock) {
 	case CLOCK_REALTIME:
@@ -215,16 +212,15 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
 		return -EINVAL;
 	}
 
-	if (compat_get_timespec(&t, rqtp))
+	if (compat_get_timespec64(&t, rqtp))
 		return -EFAULT;
-	t64 = timespec_to_timespec64(t);
-	if (!timespec64_valid(&t64))
+	if (!timespec64_valid(&t))
 		return -EINVAL;
 	if (flags & TIMER_ABSTIME)
 		rmtp = NULL;
 	current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
 	current->restart_block.nanosleep.compat_rmtp = rmtp;
-	return hrtimer_nanosleep(&t64, flags & TIMER_ABSTIME ?
+	return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
 				 which_clock);
 }

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

end of thread, other threads:[~2017-10-17 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 18:29 [PATCH] posix-stubs: use get_timespec64() and put_timespec64() Arnd Bergmann
2017-10-13 19:22 ` Nicolas Pitre
2017-10-17 15:42 ` [tip:timers/core] posix-stubs: Use " tip-bot for 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.