The patch titled time: fix msecs_to_jiffies() bug has been removed from the -mm tree. Its filename is time-fix-msecs_to_jiffies-bug.patch This patch was dropped because an updated version was merged ------------------------------------------------------ Subject: time: fix msecs_to_jiffies() bug From: Ingo Molnar <mingo@xxxxxxx> Fix multiple conversion bugs in msecs_to_jiffies(). The main problem is that this condition: if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) overflows if HZ is smaller than 1000! This change is user-visible: for HZ=250 SUS-compliant poll()-timeout value of -20 is mistakenly converted to 'immediate timeout'. (The new dyntick code also triggered this, as it frequently creates 'lagging timer wheel' scenarios.) Signed-off-by: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: john stultz <johnstul@xxxxxxxxxx> Cc: Roman Zippel <zippel@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- kernel/time.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff -puN kernel/time.c~time-fix-msecs_to_jiffies-bug kernel/time.c --- a/kernel/time.c~time-fix-msecs_to_jiffies-bug +++ a/kernel/time.c @@ -500,15 +500,56 @@ unsigned int jiffies_to_usecs(const unsi } EXPORT_SYMBOL(jiffies_to_usecs); +/* + * When we convert to jiffies then we interpret incoming values + * the following way: + * + * - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET) + * + * - 'too large' values [that would result in larger than + * MAX_JIFFY_OFFSET values] mean 'infinite timeout' too. + * + * - all other values are converted to jiffies by either multiplying + * the input value by a factor or dividing it with a factor + * + * We must also be careful about 32-bit overflows. + */ unsigned long msecs_to_jiffies(const unsigned int m) { - if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + /* + * Negative value, means infinite timeout: + */ + if ((int)m < 0) return MAX_JIFFY_OFFSET; + #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + /* + * HZ is equal to or smaller than 1000, and 1000 is a nice + * round multiple of HZ, divide with the factor between them, + * but round upwards: + */ return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + /* + * HZ is larger than 1000, and HZ is a nice round multiple of + * 1000 - simply multiply with the factor between them. + * + * But first make sure the multiplication result cannot + * overflow: + */ + if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; + return m * (HZ / MSEC_PER_SEC); #else + /* + * Generic case - multiply, round and divide. But first + * check that if we are doing a net multiplication, that + * we wouldnt overflow: + */ + if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) + return MAX_JIFFY_OFFSET; + return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; #endif } _ Patches currently in -mm which might be from mingo@xxxxxxx are forcedeth-hardirq-lockdep-warning.patch bonding-lockdep-annotation.patch spinlock-debug-all-cpu-backtrace.patch spinlock-debug-all-cpu-backtrace-fix.patch spinlock-debug-all-cpu-backtrace-fix-2.patch spinlock-debug-all-cpu-backtrace-fix-3.patch remove-the-old-bd_mutex-lockdep-annotation.patch new-bd_mutex-lockdep-annotation.patch sched-add-above-background-load-function.patch mm-implement-swap-prefetching.patch sched-cleanup-remove-task_t-convert-to-struct-task_struct-prefetch.patch time-fix-msecs_to_jiffies-bug.patch time-fix-timeout-overflow.patch cleanup-uninline-irq_enter-and-move-it-into-a.patch dynticks-extend-next_timer_interrupt-to-use-a.patch hrtimers-namespace-and-enum-cleanup.patch hrtimers-clean-up-locking.patch hrtimers-state-tracking.patch hrtimers-state-tracking-fix.patch hrtimers-clean-up-callback-tracking.patch hrtimers-move-and-add-documentation.patch clockevents-core.patch clockevents-drivers-for-i386.patch clockevents-drivers-for-i386-fix.patch clockevents-drivers-for-i386-fix-2.patch clockevents-drivers-for-i386-mystery-fix.patch high-res-timers-core.patch high-res-timers-core-fix.patch high-res-timers-core-fix-2.patch dynticks-core.patch dynticks-core-nmi-watchdog-fix.patch dynticks-core-nmi-watchdog-fix-2.patch dynticks-core-fix-idle-time-accounting.patch dyntick-add-nohz-stats-to-proc-stat.patch dynticks-i386-arch-code.patch high-res-timers-dynticks-enable-i386-support.patch debugging-feature-timer-stats.patch debugging-feature-timer-stats-fix.patch detect-atomic-counter-underflows.patch debug-shared-irqs.patch make-frame_pointer-default=y.patch mutex-subsystem-synchro-test-module.patch vdso-print-fatal-signals.patch vdso-improve-print_fatal_signals-support-by-adding-memory-maps.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html