From: Sasha Levin Date: Tue, 2 Dec 2014 04:04:06 +0000 (-0500) Subject: time: Make sure tz_minuteswest is set to a valid value when setting time X-Git-Tag: v4.2-rc1~165^2~38 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6f7d79849a00bba82d3139ff91ff2aaabd12841e;p=karo-tx-linux.git time: Make sure tz_minuteswest is set to a valid value when setting time Invalid values may overflow later, leading to undefined behaviour when multiplied by 60 to get the amount of seconds. Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: John Stultz --- diff --git a/kernel/time/time.c b/kernel/time/time.c index c42c2c3214fe..972e3bbac963 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -173,6 +173,10 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) return error; if (tz) { + /* Verify we're witin the +-15 hrs range */ + if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60) + return -EINVAL; + sys_tz = *tz; update_vsyscall_tz(); if (firsttime) {