aboutsummaryrefslogtreecommitdiff
path: root/kernel/time/ntp.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time/ntp.c')
-rw-r--r--kernel/time/ntp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index d6132cde9ba3..0cc6c9fe9416 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -671,6 +671,17 @@ int ntp_validate_timex(struct timex *txc)
if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
return -EPERM;
+ /*
+ * Check for potential multiplication overflows that can
+ * only happen on 64-bit systems:
+ */
+ if ((txc->modes & ADJ_FREQUENCY) && (BITS_PER_LONG == 64)) {
+ if (LLONG_MIN / PPM_SCALE > txc->freq)
+ return -EINVAL;
+ if (LLONG_MAX / PPM_SCALE < txc->freq)
+ return -EINVAL;
+ }
+
return 0;
}