Skip to content

Commit b5bd6a0

Browse files
jankaratorvalds
authored andcommitted
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 <[email protected]> Reported-by: Borislav Petkov <[email protected]> Reported-by: Srivatsa S. Bhat <[email protected]> Cc: Wu Fengguang <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0e75898 commit b5bd6a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/flex_proportions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void fprop_global_destroy(struct fprop_global *p)
6262
*/
6363
bool fprop_new_period(struct fprop_global *p, int periods)
6464
{
65-
u64 events;
65+
s64 events;
6666
unsigned long flags;
6767

6868
local_irq_save(flags);

0 commit comments

Comments
 (0)