Re: [PATCH] Fix half-Y2K38 problem in timecompare_update while calculating offset

From: AmÃrico Wang
Date: Wed Sep 30 2009 - 01:35:40 EST


On Mon, Sep 28, 2009 at 6:16 PM, Barry Song <21cnbao@xxxxxxxxx> wrote:
> ktime will overflow from 03:14:07 UTC on Tuesday, 19 January 2038,
> ktime_add() in timecompare_update() will overflow a half earlier.
> As a result, wrong offset will be gotten, then cause some strange
> problems.
> ---
> Âkernel/time/timecompare.c | Â Â2 +-
> Â1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/time/timecompare.c b/kernel/time/timecompare.c
> index 71e7f1a..d2d893e 100644
> --- a/kernel/time/timecompare.c
> +++ b/kernel/time/timecompare.c
> @@ -89,7 +89,7 @@ int timecompare_offset(struct timecompare *sync,
> Â Â Â Â Â Â Â Â Â Â Â Â * source time
> Â Â Â Â Â Â Â Â Â Â Â Â */
> Â Â Â Â Â Â Â Â Â Â Â Âsample.offset =
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ktime_to_ns(ktime_add(end, start)) / 2 -
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âts;
>
> Â Â Â Â Â Â Â Â Â Â Â Â/* simple insertion sort based on duration */

Just please add your Signed-off-by.

I think you catch the right thing, so

Acked-by: WANG Cong <xiyou.wangcong@xxxxxxxxx>

Add Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/