Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 5e5aeb4

Browse files
sashalevinjohnstultz-work
authored andcommitted
time: adjtimex: Validate the ADJ_FREQUENCY values
Verify that the frequency value from userspace is valid and makes sense. Unverified values can cause overflows later on. Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: stable <[email protected]> Signed-off-by: Sasha Levin <[email protected]> [jstultz: Fix up bug for negative values and drop redunent cap check] Signed-off-by: John Stultz <[email protected]>
1 parent 6ada1fc commit 5e5aeb4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/time/ntp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,13 @@ int ntp_validate_timex(struct timex *txc)
633633
if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
634634
return -EPERM;
635635

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+
636643
return 0;
637644
}
638645

0 commit comments

Comments
 (0)