time: Make sure tz_minuteswest is set to a valid value when setting time
authorSasha Levin <sasha.levin@oracle.com>
Tue, 2 Dec 2014 04:04:06 +0000 (23:04 -0500)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 22 May 2015 16:12:22 +0000 (09:12 -0700)
Invalid values may overflow later, leading to undefined behaviour when
multiplied by 60 to get the amount of seconds.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/time/time.c

index c42c2c3214fe7270168ba394d239d8a84aa985ed..972e3bbac9639911d28a3a46258494da4ae08f62 100644 (file)
@@ -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) {