Skip to content

Commit b9cc7d8

Browse files
Ben DaiKAGA-KOKO
authored andcommitted
genirq/timings: Prevent potential array overflow in __irq_timings_store()
When the interrupt interval is greater than 2 ^ PREDICTION_BUFFER_SIZE * PREDICTION_FACTOR us and less than 1s, the calculated index will be greater than the length of irqs->ema_time[]. Check the calculated index before using it to prevent array overflow. Fixes: 23aa3b9 ("genirq/timings: Encapsulate storing function") Signed-off-by: Ben Dai <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent ff363f4 commit b9cc7d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/irq/timings.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,11 @@ static __always_inline void __irq_timings_store(int irq, struct irqt_stat *irqs,
453453
*/
454454
index = irq_timings_interval_index(interval);
455455

456+
if (index > PREDICTION_BUFFER_SIZE - 1) {
457+
irqs->count = 0;
458+
return;
459+
}
460+
456461
/*
457462
* Store the index as an element of the pattern in another
458463
* circular array.

0 commit comments

Comments
 (0)