timekeeping: fix getboottime() sets invalid value
PATCH 1/1 timekeeping: fix getboottime() sets invalid value
From: Hiroshi Shimamoto <[email protected]>
Don't use timespec_add_safe() with wall_to_monotonic, because wall_to_monotonic has negative values which will cause overflow in timespec_add_safe(). That makes btime in /proc/stat invalid.
Signed-off-by Hiroshi Shimamoto <[email protected]>
--- kernel/time/timekeeping.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
kernel/time/timekeeping.c +4 -2
@@ -826,9 +826,11 @@ void update_wall_time(void)*/ void getboottime (struct timespec *ts) { -struct timespec boottime; +struct timespec boottime = { + .tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec, + .tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec + }; - boottime =timespec_add_safe (wall_to_monotonic, total_sleep_time);set_normalized_timespec (ts, -boottime.tv_sec, -boottime.tv_nsec); }
Signature · 1 line
1.6.3.3
[tip:timers/core] timekeeping: Fix invalid getboottime() value
Commit-ID: 36d47481b3824b661b464077db95d447984df799 Gitweb: http://git.kernel.org/tip/36d47481b3824b661b464077db95d447984df799 Author: Hiroshi Shimamoto <[email protected]> AuthorDate: Tue, 25 Aug 2009 15:08:30 +0900 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 25 Aug 2009 09:09:02 +0200
timekeeping: Fix invalid getboottime() value
Don't use timespec_add_safe() with wall_to_monotonic, because wall_to_monotonic has negative values which will cause overflow in timespec_add_safe(). That makes btime in /proc/stat invalid.
Signed-off-by Hiroshi Shimamoto <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc John Stultz <[email protected]>
Cc Daniel Walker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- kernel/time/timekeeping.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
kernel/time/timekeeping.c +4 -2
@@ -826,9 +826,11 @@ void update_wall_time(void)*/ void getboottime (struct timespec *ts) { -struct timespec boottime; +struct timespec boottime = { + .tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec, + .tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec + }; - boottime =timespec_add_safe (wall_to_monotonic, total_sleep_time);set_normalized_timespec (ts, -boottime.tv_sec, -boottime.tv_nsec); }