提交 b73f0c8f 编写于 作者: L Linus Torvalds

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

Pull timer fixes from Thomas Gleixner:
 "A set of small fixes:

   - regression fix for exynos_mct clocksource

   - trivial build fix for kona clocksource

   - functional one liner fix for the sh_tmu clocksource

   - two validation fixes to prevent (root only) data corruption in the
     kernel via settimeofday and adjtimex.  Tagged for stable"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  time: adjtimex: Validate the ADJ_FREQUENCY values
  time: settimeofday: Validate the values of tv from user
  clocksource: sh_tmu: Set cpu_possible_mask to fix SMP broadcast
  clocksource: kona: fix __iomem annotation
  clocksource: exynos_mct: Fix bitmask regression for exynos4_mct_write
...@@ -68,9 +68,8 @@ static void kona_timer_disable_and_clear(void __iomem *base) ...@@ -68,9 +68,8 @@ static void kona_timer_disable_and_clear(void __iomem *base)
} }
static void static void
kona_timer_get_counter(void *timer_base, uint32_t *msw, uint32_t *lsw) kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw)
{ {
void __iomem *base = IOMEM(timer_base);
int loop_limit = 4; int loop_limit = 4;
/* /*
...@@ -86,9 +85,9 @@ kona_timer_get_counter(void *timer_base, uint32_t *msw, uint32_t *lsw) ...@@ -86,9 +85,9 @@ kona_timer_get_counter(void *timer_base, uint32_t *msw, uint32_t *lsw)
*/ */
while (--loop_limit) { while (--loop_limit) {
*msw = readl(base + KONA_GPTIMER_STCHI_OFFSET); *msw = readl(timer_base + KONA_GPTIMER_STCHI_OFFSET);
*lsw = readl(base + KONA_GPTIMER_STCLO_OFFSET); *lsw = readl(timer_base + KONA_GPTIMER_STCLO_OFFSET);
if (*msw == readl(base + KONA_GPTIMER_STCHI_OFFSET)) if (*msw == readl(timer_base + KONA_GPTIMER_STCHI_OFFSET))
break; break;
} }
if (!loop_limit) { if (!loop_limit) {
......
...@@ -97,8 +97,8 @@ static void exynos4_mct_write(unsigned int value, unsigned long offset) ...@@ -97,8 +97,8 @@ static void exynos4_mct_write(unsigned int value, unsigned long offset)
writel_relaxed(value, reg_base + offset); writel_relaxed(value, reg_base + offset);
if (likely(offset >= EXYNOS4_MCT_L_BASE(0))) { if (likely(offset >= EXYNOS4_MCT_L_BASE(0))) {
stat_addr = (offset & ~EXYNOS4_MCT_L_MASK) + MCT_L_WSTAT_OFFSET; stat_addr = (offset & EXYNOS4_MCT_L_MASK) + MCT_L_WSTAT_OFFSET;
switch (offset & EXYNOS4_MCT_L_MASK) { switch (offset & ~EXYNOS4_MCT_L_MASK) {
case MCT_L_TCON_OFFSET: case MCT_L_TCON_OFFSET:
mask = 1 << 3; /* L_TCON write status */ mask = 1 << 3; /* L_TCON write status */
break; break;
......
...@@ -428,7 +428,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, ...@@ -428,7 +428,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch,
ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features = CLOCK_EVT_FEAT_PERIODIC;
ced->features |= CLOCK_EVT_FEAT_ONESHOT; ced->features |= CLOCK_EVT_FEAT_ONESHOT;
ced->rating = 200; ced->rating = 200;
ced->cpumask = cpumask_of(0); ced->cpumask = cpu_possible_mask;
ced->set_next_event = sh_tmu_clock_event_next; ced->set_next_event = sh_tmu_clock_event_next;
ced->set_mode = sh_tmu_clock_event_mode; ced->set_mode = sh_tmu_clock_event_mode;
ced->suspend = sh_tmu_clock_event_suspend; ced->suspend = sh_tmu_clock_event_suspend;
......
...@@ -110,6 +110,19 @@ static inline bool timespec_valid_strict(const struct timespec *ts) ...@@ -110,6 +110,19 @@ static inline bool timespec_valid_strict(const struct timespec *ts)
return true; return true;
} }
static inline bool timeval_valid(const struct timeval *tv)
{
/* Dates before 1970 are bogus */
if (tv->tv_sec < 0)
return false;
/* Can't have more microseconds then a second */
if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
return false;
return true;
}
extern struct timespec timespec_trunc(struct timespec t, unsigned gran); extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
#define CURRENT_TIME (current_kernel_time()) #define CURRENT_TIME (current_kernel_time())
......
...@@ -633,6 +633,13 @@ int ntp_validate_timex(struct timex *txc) ...@@ -633,6 +633,13 @@ 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)
return -EINVAL;
if (LONG_MAX / PPM_SCALE < txc->freq)
return -EINVAL;
}
return 0; return 0;
} }
......
...@@ -196,6 +196,10 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv, ...@@ -196,6 +196,10 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
if (tv) { if (tv) {
if (copy_from_user(&user_tv, tv, sizeof(*tv))) if (copy_from_user(&user_tv, tv, sizeof(*tv)))
return -EFAULT; return -EFAULT;
if (!timeval_valid(&user_tv))
return -EINVAL;
new_ts.tv_sec = user_tv.tv_sec; new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC; new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册