* [PATCH v3] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
@ 2025-09-19 3:27 Joonwon Kang
0 siblings, 0 replies; only message in thread
From: Joonwon Kang @ 2025-09-19 3:27 UTC (permalink / raw)
To: jassisinghbrar, peng.fan; +Cc: linux-kernel, Joonwon Kang
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-19 3:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19 3:27 [PATCH v3] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate() Joonwon Kang
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®