From: Joonwon Kang <joonwonkang@google.com>
To: jassisinghbrar@gmail.com, peng.fan@oss.nxp.com
Cc: linux-kernel@vger.kernel.org, Joonwon Kang <joonwonkang@google.com>
Subject: [PATCH v3] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
Date: Fri, 19 Sep 2025 03:27:14 +0000 [thread overview]
Message-ID: <20250919032714.948213-1-joonwonkang@google.com> (raw)
Although it is guided that `#mbox-cells` must be at least 1, there are
many instances of `#mbox-cells = <0>;` in the device tree. If that is
the case and the corresponding mailbox controller does not provide
`of_xlate` function pointer, `of_mbox_index_xlate()` will be used by
default and out-of-bounds accesses could occur due to lack of bounds
check in that function.
Signed-off-by: Joonwon Kang <joonwonkang@google.com>
---
drivers/mailbox/mailbox.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 5cd8ae222073..5bccdf27d6ab 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -476,7 +476,7 @@ of_mbox_index_xlate(struct mbox_controller *mbox,
{
int ind = sp->args[0];
- if (ind >= mbox->num_chans)
+ if (sp->args_count < 1 || ind >= mbox->num_chans)
return ERR_PTR(-EINVAL);
return &mbox->chans[ind];
--
2.51.0.470.ga7dc726c21-goog
reply other threads:[~2025-09-19 3:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250919032714.948213-1-joonwonkang@google.com \
--to=joonwonkang@google.com \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@oss.nxp.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®