posix-timers: Fix clock_adjtime to return timex data on success
PATCH 1/1 posix-timers: Fix clock_adjtime to return timex data on success
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.
--- kernel/posix-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/posix-timers.c +1 -1
@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, err = kc->clock_adj (which_clock, &ktx); -if (!err &©_to_user (utx, &ktx,sizeof (ktx))) +if (err >=0 &©_to_user (utx, &ktx,sizeof (ktx)))return -EFAULT ;return err;
Signature · 1 line
1.7.11.7
Quoted 5 lines · Miroslav Lichvar
Copy the modified timex data back to the user also with positive return values. This fixes reading of the
CLOCK_REALTIMEtimex data when the clock is in a non-zero state.Signed-off-by Miroslav Lichvar <[email protected]>
(Adding John Stultz on CC)
Quoted 20 lines
--- kernel/posix-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/posix-timers.c +1
-1@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, err = kc->clock_adj (which_clock, &ktx); -if (!err &©_to_user (utx, &ktx,sizeof (ktx))) +if (err >=0 &©_to_user (utx, &ktx,sizeof (ktx)))return -EFAULT ;return err;Signature · 1 line
1.7.11.7
Quoted 9 lines · Richard Cochran
Quoted 5 lines · Miroslav Lichvar
Copy the modified timex data back to the user also with positive return values. This fixes reading of the
CLOCK_REALTIMEtimex data when the clock is in a non-zero state.Signed-off-by Miroslav Lichvar <[email protected]>Acked-by Richard Cochran <[email protected]>(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
PATCH v2 1/1 posix-timers: Fix clock_adjtime to always return timex data on success
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.
--- kernel/posix-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/posix-timers.c +1 -1
@@ -997,7 +997,7 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, err = kc->clock_adj (which_clock, &ktx); -if (!err &©_to_user (utx, &ktx,sizeof (ktx))) +if (err >=0 &©_to_user (utx, &ktx,sizeof (ktx)))return -EFAULT ;return err;
Signature · 1 line
1.7.11.7
Re: [PATCHv2] posix-timers: Fix clock_adjtime to always return timex data on success
Quoted 6 lines · Miroslav Lichvar
The
clock_adjcall 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 <[email protected]>
Thanks for the resend. I've got this in my queue for 3.9
thanks
-john