diff options
Diffstat (limited to 'kernel/time/ntp.c')
| -rw-r--r-- | kernel/time/ntp.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 28bf91c60a0b..0f60b08a4f07 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
| @@ -488,13 +488,13 @@ static void sync_cmos_clock(struct work_struct *work) | |||
| 488 | 488 | ||
| 489 | getnstimeofday64(&now); | 489 | getnstimeofday64(&now); |
| 490 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) { | 490 | if (abs(now.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec * 5) { |
| 491 | struct timespec adjust = timespec64_to_timespec(now); | 491 | struct timespec64 adjust = now; |
| 492 | 492 | ||
| 493 | fail = -ENODEV; | 493 | fail = -ENODEV; |
| 494 | if (persistent_clock_is_local) | 494 | if (persistent_clock_is_local) |
| 495 | adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); | 495 | adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); |
| 496 | #ifdef CONFIG_GENERIC_CMOS_UPDATE | 496 | #ifdef CONFIG_GENERIC_CMOS_UPDATE |
| 497 | fail = update_persistent_clock(adjust); | 497 | fail = update_persistent_clock(timespec64_to_timespec(adjust)); |
| 498 | #endif | 498 | #endif |
| 499 | #ifdef CONFIG_RTC_SYSTOHC | 499 | #ifdef CONFIG_RTC_SYSTOHC |
| 500 | if (fail == -ENODEV) | 500 | if (fail == -ENODEV) |
| @@ -633,10 +633,14 @@ int ntp_validate_timex(struct timex *txc) | |||
| 633 | if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) | 633 | if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) |
| 634 | return -EPERM; | 634 | return -EPERM; |
| 635 | 635 | ||
| 636 | if (txc->modes & ADJ_FREQUENCY) { | 636 | /* |
| 637 | if (LONG_MIN / PPM_SCALE > txc->freq) | 637 | * Check for potential multiplication overflows that can |
| 638 | * only happen on 64-bit systems: | ||
| 639 | */ | ||
| 640 | if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) { | ||
| 641 | if (LLONG_MIN / PPM_SCALE > txc->freq) | ||
| 638 | return -EINVAL; | 642 | return -EINVAL; |
| 639 | if (LONG_MAX / PPM_SCALE < txc->freq) | 643 | if (LLONG_MAX / PPM_SCALE < txc->freq) |
| 640 | return -EINVAL; | 644 | return -EINVAL; |
| 641 | } | 645 | } |
| 642 | 646 | ||
