diff options
author | Jan Kara <jack@suse.cz> | 2012-09-24 17:17:35 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-25 08:59:21 -0700 |
commit | b5bd6a0e5fa8c0376d9746c566fe3daaa51ec825 (patch) | |
tree | ac746aa7a4f21b9ac4161b66fce9965ffeda9cb1 /lib/flex_proportions.c | |
parent | 0e75898fe2499ece0ac3f1475982a828b3283b0d (diff) | |
download | linux-b5bd6a0e5fa8c0376d9746c566fe3daaa51ec825.tar.gz linux-b5bd6a0e5fa8c0376d9746c566fe3daaa51ec825.tar.bz2 linux-b5bd6a0e5fa8c0376d9746c566fe3daaa51ec825.zip |
lib/flex_proportions.c: fix corruption of denominator in flexible proportions
When racing with CPU hotplug, percpu_counter_sum() can return negative
values for the number of observed events.
This confuses fprop_new_period(), which uses unsigned type and as a
result number of events is set to big *positive* number. From that
moment on, things go pear shaped and can result e.g. in division by
zero as denominator is later truncated to 32-bits.
This bug causes a divide-by-zero oops in bdi_dirty_limit() in Borislav's
3.6.0-rc6 based kernel.
Fix the issue by using a signed type in fprop_new_period(). That makes
us bail out from the function without doing anything (mistakenly)
thinking there are no events to age. That makes aging somewhat
inaccurate but getting accurate data would be rather hard.
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Borislav Petkov <bp@amd64.org>
Reported-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/flex_proportions.c')
-rw-r--r-- | lib/flex_proportions.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/flex_proportions.c b/lib/flex_proportions.c index c785554f9523..ebf3bac460b0 100644 --- a/lib/flex_proportions.c +++ b/lib/flex_proportions.c @@ -62,7 +62,7 @@ void fprop_global_destroy(struct fprop_global *p) */ bool fprop_new_period(struct fprop_global *p, int periods) { - u64 events; + s64 events; unsigned long flags; local_irq_save(flags); |