Skip to contentSkip to conversation

Fix half-Y2K38 problem in timecompare_update while calculating offset

PATCH In review Barry Song 3 participants 5 messages Sep 28, 2009 – Jan 6, 2010

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 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.

---
 kernel/time/timecompare.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/timecompare.c +1 -1
index 71e7f1a..d2d893e 100644
@@ -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 */
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 4 lines · 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.

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

#2 lore raw
Quoted 7 lines · Mike Frysinger
Quoted 4 lines · 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.

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

author
#3 lore raw

It has been merged into mainline:

timecompare: fix half-Y2K38 problem in timecompare_update while calculating offset
author Barry Song <[email protected]>

	Wed, 16 Dec 2009 00:45:34 +0000 (16:45 -0800)
committer	Linus Torvalds <[email protected]>	
	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.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Patrick Ohly <[email protected]>
Cc David S. Miller <[email protected]>
Cc John Stultz <[email protected]>
Quoted 12 lines · Mike Frysinger
Quoted 7 lines · Mike Frysinger
Quoted 4 lines · 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.

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

Acked-by on v1 1/1
#4 lore raw
In reply to Barry Song
Quoted 20 lines · 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(-)
kernel/time/timecompare.c +0 -0
index 71e7f1a..d2d893e 100644
@@ -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;

Quoted 1 line

                       /* simple insertion sort based on duration */

Just please add your Signed-off-by.

I think you catch the right thing, so

Add Cc: Thomas Gleixner <[email protected]>.