linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix half-Y2K38 problem in timecompare_update while calculating offset
@ 2009-09-28 10:16 Barry Song
  2009-09-30  2:44 ` Mike Frysinger
  2009-09-30  5:35 ` Américo Wang
  0 siblings, 2 replies; 5+ messages in thread
From: Barry Song @ 2009-09-28 10:16 UTC (permalink / raw)
  To: akpm, davem, patrick.ohly; +Cc: uclinux-dist-devel, linux-kernel, Barry Song

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 */
-- 
1.5.6.3


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

* Re: [PATCH] Fix half-Y2K38 problem in timecompare_update while  calculating offset
  2009-09-28 10:16 [PATCH] Fix half-Y2K38 problem in timecompare_update while calculating offset Barry Song
@ 2009-09-30  2:44 ` Mike Frysinger
  2010-01-05 19:28   ` Mike Frysinger
  2009-09-30  5:35 ` Américo Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2009-09-30  2:44 UTC (permalink / raw)
  To: Barry Song; +Cc: akpm, davem, patrick.ohly, uclinux-dist-devel, linux-kernel

On Mon, Sep 28, 2009 at 06:16, Barry Song 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.

Barry: you forgot to include your s-o-b tag ...
-mike

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

* Re: [PATCH] Fix half-Y2K38 problem in timecompare_update while  calculating offset
  2009-09-28 10:16 [PATCH] Fix half-Y2K38 problem in timecompare_update while calculating offset Barry Song
  2009-09-30  2:44 ` Mike Frysinger
@ 2009-09-30  5:35 ` Américo Wang
  1 sibling, 0 replies; 5+ messages in thread
From: Américo Wang @ 2009-09-30  5:35 UTC (permalink / raw)
  To: Barry Song
  Cc: akpm, davem, patrick.ohly, uclinux-dist-devel, linux-kernel,
	Thomas Gleixner

On Mon, Sep 28, 2009 at 6:16 PM, Barry Song <21cnbao@gmail.com> 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@gmail.com>

Add Cc: Thomas Gleixner <tglx@linutronix.de>.

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

* Re: [PATCH] Fix half-Y2K38 problem in timecompare_update while  calculating offset
  2009-09-30  2:44 ` Mike Frysinger
@ 2010-01-05 19:28   ` Mike Frysinger
  2010-01-06  3:18     ` Barry Song
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2010-01-05 19:28 UTC (permalink / raw)
  To: Barry Song; +Cc: akpm, davem, patrick.ohly, uclinux-dist-devel, linux-kernel

On Tue, Sep 29, 2009 at 21:44, Mike Frysinger wrote:
> On Mon, Sep 28, 2009 at 06:16, Barry Song 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.
>
> Barry: you forgot to include your s-o-b tag ...

you still need to post your s-o-b if we want this to go any further
-mike

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

* Re: [PATCH] Fix half-Y2K38 problem in timecompare_update while  calculating offset
  2010-01-05 19:28   ` Mike Frysinger
@ 2010-01-06  3:18     ` Barry Song
  0 siblings, 0 replies; 5+ messages in thread
From: Barry Song @ 2010-01-06  3:18 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: akpm, davem, patrick.ohly, uclinux-dist-devel, linux-kernel

It has been merged into mainline:

timecompare: fix half-Y2K38 problem in timecompare_update while
calculating offset
author	Barry Song <21cnbao@gmail.com>	
	Wed, 16 Dec 2009 00:45:34 +0000 (16:45 -0800)
committer	Linus Torvalds <torvalds@linux-foundation.org>	
	Wed, 16 Dec 2009 15:19:57 +0000 (07:19 -0800)
commit	f065f41f48569122b5bcddbd1ba2354f7cc29fdc
tree	68606305bfb3aba16437017e0596ccae11e6f6db	tree | snapshot
parent	4365a5676fa3aa1d5ae6c90c22a0044f09ba584e	commit | diff
timecompare: fix half-Y2K38 problem in timecompare_update while
calculating offset

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.

Signed-off-by: Barry Song <21cnbao@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Patrick Ohly <patrick.ohly@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


On Wed, Jan 6, 2010 at 3:28 AM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> On Tue, Sep 29, 2009 at 21:44, Mike Frysinger wrote:
>> On Mon, Sep 28, 2009 at 06:16, Barry Song 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.
>>
>> Barry: you forgot to include your s-o-b tag ...
>
> you still need to post your s-o-b if we want this to go any further
> -mike
>

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

end of thread, other threads:[~2010-01-06  3:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-28 10:16 [PATCH] Fix half-Y2K38 problem in timecompare_update while calculating offset Barry Song
2009-09-30  2:44 ` Mike Frysinger
2010-01-05 19:28   ` Mike Frysinger
2010-01-06  3:18     ` Barry Song
2009-09-30  5:35 ` Américo Wang

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).