]> git.karo-electronics.de Git - karo-tx-linux.git/commit
prevent timespec/timeval to ktime_t overflow
authorThomas Gleixner <tglx@linutronix.de>
Sun, 8 Apr 2007 22:03:30 +0000 (00:03 +0200)
committerAdrian Bunk <bunk@stusta.de>
Sun, 8 Apr 2007 22:03:30 +0000 (00:03 +0200)
commit812b03dc31229847825989f5e35359a7c4dff6f4
treec684880491774be3b261f00f18e523dd0cb391d9
parent2c461b3302b33de1500267a11cc50e29f33cbde6
prevent timespec/timeval to ktime_t overflow

Frank v.  Waveren pointed out that on 64bit machines the timespec to
ktime_t conversion might overflow.  This is also true for timeval to
time_t conversions.  This breaks a "sleep inf" on 64bit machines.

While a timespec/timeval with tx.sec = MAX_LONG is valid by specification
the internal representation of ktime_t is based on nanoseconds.  The
conversion of seconds to nanoseconds overflows for seconds values >=
(MAX_LONG / NSEC_PER_SEC).

Check the seconds argument to the conversion and limit it to the maximum
time which can be represented by ktime_t.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
include/linux/ktime.h