Commit f065f41f48569122b5bcddbd1ba2354f7cc29fdc

Authored by Barry Song
Committed by Linus Torvalds
1 parent 4365a5676f

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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

kernel/time/timecompare.c
... ... @@ -89,7 +89,7 @@
89 89 * source time
90 90 */
91 91 sample.offset =
92   - ktime_to_ns(ktime_add(end, start)) / 2 -
  92 + (ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
93 93 ts;
94 94  
95 95 /* simple insertion sort based on duration */