From: Advait Dhamorikar <advaitdhamorikar@gmail.com>
To: Drew Fustini <drew@pdp7.com>, Guo Ren <guoren@kernel.org>,
Fu Wei <wefu@redhat.com>, Jassi Brar <jassisinghbrar@gmail.com>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Advait Dhamorikar <advaitdhamorikar@gmail.com>
Subject: [PATCH-next] mailbox: th1520: Fix out of bounds write
Date: Tue, 26 Nov 2024 00:40:09 +0530 [thread overview]
Message-ID: <20241125191009.28535-1-advaitdhamorikar@gmail.com> (raw)
The loop in the function iterates up to `TH_1520_MBOX_CHANS`,
but the `ctx->intr_mask` array only has 3 elements. When
`TH_1520_MBOX_CHANS` is set to a value larger than 3, this
causes an out-of-bounds write at `ctx->intr_mask[3]`.
This could cause an immediate crash or incorrect computations.
Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.com>
---
drivers/mailbox/mailbox-th1520.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mailbox/mailbox-th1520.c b/drivers/mailbox/mailbox-th1520.c
index 4e84640ac3b8..759634a4fb72 100644
--- a/drivers/mailbox/mailbox-th1520.c
+++ b/drivers/mailbox/mailbox-th1520.c
@@ -532,6 +532,9 @@ static int __maybe_unused th1520_mbox_suspend_noirq(struct device *dev)
* INFO data all assumed to be lost.
*/
for (i = 0; i < TH_1520_MBOX_CHANS; i++) {
+ if (i >= ARRAY_SIZE(ctx->intr_mask))
+ break;
+
ctx->intr_mask[i] =
ioread32(priv->local_icu[i] + TH_1520_MBOX_MASK);
}
--
2.34.1
next reply other threads:[~2024-11-25 19:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 19:10 Advait Dhamorikar [this message]
2025-01-18 19:30 ` Jassi Brar
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=20241125191009.28535-1-advaitdhamorikar@gmail.com \
--to=advaitdhamorikar@gmail.com \
--cc=drew@pdp7.com \
--cc=guoren@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=wefu@redhat.com \
/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®