Skip to content

Commit

Permalink
time: Make sure tz_minuteswest is set to a valid value when setting time
Browse files Browse the repository at this point in the history
Invalid values may overflow later, leading to undefined behaviour when
multiplied by 60 to get the amount of seconds.

Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: John Stultz <[email protected]>
  • Loading branch information
sashalevin authored and johnstultz-work committed May 22, 2015
1 parent 4e3d9cb commit 6f7d798
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/time/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6f7d798

Please sign in to comment.