History

Merge branch 'fortglx/3.19-stable/time' of https://git.linaro.org/people/john.stultz/linux into timers/urgent

Pull urgent fixes from John Stultz: Two urgent fixes for user triggerable time related overflow issues

Thomas Gleixner committed 11 years ago

Commit 5fbaba82 parents f2a5473 5e5aeb43 files · +24 −0Browse files

Unified · Split

3 files
  1. include/linux/time.h +13 −0
  2. kernel/time/ntp.c +7 −0
  3. kernel/time/time.c +4 −0
include/linux/time.h+13−0
@@ -110,6 +110,19 @@ static inline bool timespec_valid_strict(const struct timespec *ts) · 109 unmodified lines
110110 return true;
111111 }
112112
113+static inline bool timeval_valid(const struct timeval *tv)
114+{
115+ /* Dates before 1970 are bogus */
116+ if (tv->tv_sec < 0)
117+ return false;
118+
119+ /* Can't have more microseconds then a second */
120+ if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
121+ return false;
122+
123+ return true;
124+}
125+
113126 extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
114127
115128 #define CURRENT_TIME (current_kernel_time())
kernel/time/ntp.c+7−0
@@ -633,6 +633,13 @@ int ntp_validate_timex(struct timex *txc) · 632 unmodified lines
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
kernel/time/time.c+4−0
@@ -196,6 +196,10 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv, · 195 unmodified lines
196196 if (tv) {
197197 if (copy_from_user(&user_tv, tv, sizeof(*tv)))
198198 return -EFAULT;
199+
200+ if (!timeval_valid(&user_tv))
201+ return -EINVAL;
202+
199203 new_ts.tv_sec = user_tv.tv_sec;
200204 new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
201205 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t