summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorBen Dai <ben.dai@unisoc.com>2021-04-25 18:09:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-08-18 10:07:04 +0300
commit9dac5f65caaf53545d4475c57a5f30edaa2a6ece (patch)
treea871028ef5de1a5ccace1818c9ebea50b0482277 /kernel
parent0c081d4a6a138b05c591cc674f49da9bde682e94 (diff)
downloadlinux-9dac5f65caaf53545d4475c57a5f30edaa2a6ece.tar.xz
genirq/timings: Prevent potential array overflow in __irq_timings_store()
commit b9cc7d8a4656a6e815852c27ab50365009cb69c1 upstream. 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: 23aa3b9a6b7d ("genirq/timings: Encapsulate storing function") Signed-off-by: Ben Dai <ben.dai@unisoc.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210425150903.25456-1-ben.dai9703@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/irq/timings.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c
index d309d6fbf5bd..4d2a702d7aa9 100644
--- a/kernel/irq/timings.c
+++ b/kernel/irq/timings.c
@@ -453,6 +453,11 @@ static __always_inline void __irq_timings_store(int irq, struct irqt_stat *irqs,
*/
index = irq_timings_interval_index(interval);
+ if (index > PREDICTION_BUFFER_SIZE - 1) {
+ irqs->count = 0;
+ return;
+ }
+
/*
* Store the index as an element of the pattern in another
* circular array.