mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Ben Dai" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Ben Dai <ben.dai@unisoc.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	stable@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org, maz@kernel.org
Subject: [tip: irq/urgent] genirq/timings: Prevent potential array overflow in __irq_timings_store()
Date: Tue, 10 Aug 2021 13:41:19 -0000	[thread overview]
Message-ID: <162860287930.395.16257613336849312790.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210425150903.25456-1-ben.dai9703@gmail.com>

The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     b9cc7d8a4656a6e815852c27ab50365009cb69c1
Gitweb:        https://git.kernel.org/tip/b9cc7d8a4656a6e815852c27ab50365009cb69c1
Author:        Ben Dai <ben.dai@unisoc.com>
AuthorDate:    Sun, 25 Apr 2021 23:09:03 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 10 Aug 2021 15:39:00 +02:00

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: 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

---
 kernel/irq/timings.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/irq/timings.c b/kernel/irq/timings.c
index d309d6f..4d2a702 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.

      reply	other threads:[~2021-08-10 13:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25 15:09 [PATCH] genirq/timings: prevent " Ben Dai
2021-08-10 13:41 ` tip-bot2 for Ben Dai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=162860287930.395.16257613336849312790.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=ben.dai@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®