Commit e8e3b6ddd0a6afa267029141946918392b425cf4
Committed by
Greg Kroah-Hartman
1 parent
5f4d5404ee
time: adjtimex: Validate the ADJ_FREQUENCY values
commit 5e5aeb4367b450a28f447f6d5ab57d8f2ab16a5f upstream. Verify that the frequency value from userspace is valid and makes sense. Unverified values can cause overflows later on. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> [jstultz: Fix up bug for negative values and drop redunent cap check] Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff
kernel/time/ntp.c
... | ... | @@ -633,6 +633,13 @@ |
633 | 633 | if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) |
634 | 634 | return -EPERM; |
635 | 635 | |
636 | + if (txc->modes & ADJ_FREQUENCY) { | |
637 | + if (LONG_MIN / PPM_SCALE > txc->freq) | |
638 | + return -EINVAL; | |
639 | + if (LONG_MAX / PPM_SCALE < txc->freq) | |
640 | + return -EINVAL; | |
641 | + } | |
642 | + | |
636 | 643 | return 0; |
637 | 644 | } |
638 | 645 |