Commit 6ea565a9 authored by John Stultz's avatar John Stultz Committed by Thomas Gleixner

time: Avoid potential shift overflow with large shift values

Andreas Schwab noticed that the 1 << tk->shift could overflow if the
shift value was greater than 30, since 1 would be a 32bit long on
32bit architectures. This issue was introduced by 1e75fa8b (time:
Condense timekeeper.xtime into xtime_sec)

Use 1ULL instead to ensure we don't overflow on the shift.
Reported-by: default avatarAndreas Schwab <schwab@linux-m68k.org>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1345595449-34965-4-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 85dc8f05
...@@ -1184,9 +1184,9 @@ static void update_wall_time(void) ...@@ -1184,9 +1184,9 @@ static void update_wall_time(void)
* the vsyscall implementations are converted to use xtime_nsec * the vsyscall implementations are converted to use xtime_nsec
* (shifted nanoseconds), this can be killed. * (shifted nanoseconds), this can be killed.
*/ */
remainder = tk->xtime_nsec & ((1 << tk->shift) - 1); remainder = tk->xtime_nsec & ((1ULL << tk->shift) - 1);
tk->xtime_nsec -= remainder; tk->xtime_nsec -= remainder;
tk->xtime_nsec += 1 << tk->shift; tk->xtime_nsec += 1ULL << tk->shift;
tk->ntp_error += remainder << tk->ntp_error_shift; tk->ntp_error += remainder << tk->ntp_error_shift;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment