linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] posix-timers: Fix clock_adjtime to return timex data on success
@ 2013-01-10 17:12 Miroslav Lichvar
  2013-01-10 20:12 ` Richard Cochran
  0 siblings, 1 reply; 5+ messages in thread
From: Miroslav Lichvar @ 2013-01-10 17:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Richard Cochran, Miroslav Lichvar

Copy the modified timex data back to the user also with positive return
values. This fixes reading of the CLOCK_REALTIME timex data when the
clock is in a non-zero state.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
---
 kernel/posix-timers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 69185ae..10349d5 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
 
 	err = kc->clock_adj(which_clock, &ktx);
 
-	if (!err && copy_to_user(utx, &ktx, sizeof(ktx)))
+	if (err >= 0 && copy_to_user(utx, &ktx, sizeof(ktx)))
 		return -EFAULT;
 
 	return err;
-- 
1.7.11.7


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

* Re: [PATCH] posix-timers: Fix clock_adjtime to return timex data on success
  2013-01-10 17:12 [PATCH] posix-timers: Fix clock_adjtime to return timex data on success Miroslav Lichvar
@ 2013-01-10 20:12 ` Richard Cochran
  2013-01-10 20:27   ` John Stultz
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Cochran @ 2013-01-10 20:12 UTC (permalink / raw)
  To: Miroslav Lichvar; +Cc: linux-kernel, Thomas Gleixner, John Stultz

On Thu, Jan 10, 2013 at 06:12:02PM +0100, Miroslav Lichvar wrote:
> Copy the modified timex data back to the user also with positive return
> values. This fixes reading of the CLOCK_REALTIME timex data when the
> clock is in a non-zero state.
> 
> Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>

Acked-by: Richard Cochran <richardcochran@gmail.com>

(Adding John Stultz on CC)

> ---
>  kernel/posix-timers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
> index 69185ae..10349d5 100644
> --- a/kernel/posix-timers.c
> +++ b/kernel/posix-timers.c
> @@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
>  
>  	err = kc->clock_adj(which_clock, &ktx);
>  
> -	if (!err && copy_to_user(utx, &ktx, sizeof(ktx)))
> +	if (err >= 0 && copy_to_user(utx, &ktx, sizeof(ktx)))
>  		return -EFAULT;
>  
>  	return err;
> -- 
> 1.7.11.7
> 

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

* Re: [PATCH] posix-timers: Fix clock_adjtime to return timex data on success
  2013-01-10 20:12 ` Richard Cochran
@ 2013-01-10 20:27   ` John Stultz
  2013-01-11 10:58     ` [PATCHv2] posix-timers: Fix clock_adjtime to always " Miroslav Lichvar
  0 siblings, 1 reply; 5+ messages in thread
From: John Stultz @ 2013-01-10 20:27 UTC (permalink / raw)
  To: Richard Cochran; +Cc: Miroslav Lichvar, linux-kernel, Thomas Gleixner

On 01/10/2013 12:12 PM, Richard Cochran wrote:
> On Thu, Jan 10, 2013 at 06:12:02PM +0100, Miroslav Lichvar wrote:
>> Copy the modified timex data back to the user also with positive return
>> values. This fixes reading of the CLOCK_REALTIME timex data when the
>> clock is in a non-zero state.
>>
>> Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
> Acked-by: Richard Cochran <richardcochran@gmail.com>
>
> (Adding John Stultz on CC)

Just to clarify (the commit message makes it pretty hard to understand 
exactly what's going wrong), this is to handle the case where 
clock_adj() returns a non-zero time_state value (such as TIME_INS) ?

thanks
-john


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

* [PATCHv2] posix-timers: Fix clock_adjtime to always return timex data on success
  2013-01-10 20:27   ` John Stultz
@ 2013-01-11 10:58     ` Miroslav Lichvar
  2013-01-12  2:29       ` John Stultz
  0 siblings, 1 reply; 5+ messages in thread
From: Miroslav Lichvar @ 2013-01-11 10:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: John Stultz, Thomas Gleixner, Richard Cochran, Miroslav Lichvar

The clock_adj call returns the clock state on success, which may be a
non-zero value (e.g. TIME_INS), but the modified timex data is copied
back to the user only when zero value (TIME_OK) was returned. Fix the
condition to copy the data also with positive return values.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
---
 kernel/posix-timers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 69185ae..10349d5 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
 
 	err = kc->clock_adj(which_clock, &ktx);
 
-	if (!err && copy_to_user(utx, &ktx, sizeof(ktx)))
+	if (err >= 0 && copy_to_user(utx, &ktx, sizeof(ktx)))
 		return -EFAULT;
 
 	return err;
-- 
1.7.11.7


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

* Re: [PATCHv2] posix-timers: Fix clock_adjtime to always return timex data on success
  2013-01-11 10:58     ` [PATCHv2] posix-timers: Fix clock_adjtime to always " Miroslav Lichvar
@ 2013-01-12  2:29       ` John Stultz
  0 siblings, 0 replies; 5+ messages in thread
From: John Stultz @ 2013-01-12  2:29 UTC (permalink / raw)
  To: Miroslav Lichvar; +Cc: linux-kernel, Thomas Gleixner, Richard Cochran

On 01/11/2013 02:58 AM, Miroslav Lichvar wrote:
> The clock_adj call returns the clock state on success, which may be a
> non-zero value (e.g. TIME_INS), but the modified timex data is copied
> back to the user only when zero value (TIME_OK) was returned. Fix the
> condition to copy the data also with positive return values.
>
> Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>

Thanks for the resend. I've got this in my queue for 3.9

thanks
-john


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

end of thread, other threads:[~2013-01-12  2:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-10 17:12 [PATCH] posix-timers: Fix clock_adjtime to return timex data on success Miroslav Lichvar
2013-01-10 20:12 ` Richard Cochran
2013-01-10 20:27   ` John Stultz
2013-01-11 10:58     ` [PATCHv2] posix-timers: Fix clock_adjtime to always " Miroslav Lichvar
2013-01-12  2:29       ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).