Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull ntp fix from Ingo Molnar:
 "An adjtimex interface regression fix for 32-bit systems"

[ A check that was added in a previous commit is really only a concern
  for 64bit systems, but was applied to both 32 and 64bit systems, which
  results in breaking 32bit systems.

  Thus the fix here is to make the check only apply to 64bit systems ]

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  ntp: Fixup adjtimex freq validation on 32-bit systems
This commit is contained in:
Linus Torvalds 2015-02-21 11:05:22 -08:00
commit f3c233d75e
1 changed files with 7 additions and 3 deletions

View File

@ -633,10 +633,14 @@ int ntp_validate_timex(struct timex *txc)
if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
return -EPERM; return -EPERM;
if (txc->modes & ADJ_FREQUENCY) { /*
if (LONG_MIN / PPM_SCALE > txc->freq) * 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; return -EINVAL;
if (LONG_MAX / PPM_SCALE < txc->freq) if (LLONG_MAX / PPM_SCALE < txc->freq)
return -EINVAL; return -EINVAL;
} }