* [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
@ 2026-03-04 7:30 Joonwon Kang
2026-03-04 9:10 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Joonwon Kang @ 2026-03-04 7:30 UTC (permalink / raw)
To: stable, jassisinghbrar; +Cc: linux-kernel, sashal, Joonwon Kang
[ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ]
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
`fw_xlate` and of_xlate` function pointers, `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.
Cc: stable@vger.kernel.org
Signed-off-by: Joonwon Kang <joonwonkang@google.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
[ changed sp->nargs to sp->args_count in the code and
fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ]
Signed-off-by: Joonwon Kang <joonwonkang@google.com>
---
drivers/mailbox/mailbox.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index d3d26a2c9895..66cdadbd3d75 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -498,12 +498,10 @@ static struct mbox_chan *
of_mbox_index_xlate(struct mbox_controller *mbox,
const struct of_phandle_args *sp)
{
- int ind = sp->args[0];
-
- if (ind >= mbox->num_chans)
+ if (sp->args_count < 1 || sp->args[0] >= mbox->num_chans)
return ERR_PTR(-EINVAL);
- return &mbox->chans[ind];
+ return &mbox->chans[sp->args[0]];
}
/**
--
2.53.0.473.g4a7958ca14-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
2026-03-04 7:30 [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate() Joonwon Kang
@ 2026-03-04 9:10 ` Greg KH
2026-03-04 11:01 ` Joonwon Kang
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2026-03-04 9:10 UTC (permalink / raw)
To: Joonwon Kang; +Cc: stable, jassisinghbrar, linux-kernel, sashal
On Wed, Mar 04, 2026 at 07:30:52AM +0000, Joonwon Kang wrote:
> [ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ]
>
> 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
> `fw_xlate` and of_xlate` function pointers, `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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Joonwon Kang <joonwonkang@google.com>
> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
> [ changed sp->nargs to sp->args_count in the code and
> fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ]
> Signed-off-by: Joonwon Kang <joonwonkang@google.com>
> ---
> drivers/mailbox/mailbox.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
What kernel tree(s) is this for?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
2026-03-04 9:10 ` Greg KH
@ 2026-03-04 11:01 ` Joonwon Kang
0 siblings, 0 replies; 3+ messages in thread
From: Joonwon Kang @ 2026-03-04 11:01 UTC (permalink / raw)
To: gregkh; +Cc: jassisinghbrar, joonwonkang, linux-kernel, sashal, stable
>> [ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ]
>>
>> 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
>> `fw_xlate` and of_xlate` function pointers, `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.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Joonwon Kang <joonwonkang@google.com>
>> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
>> [ changed sp->nargs to sp->args_count in the code and
>> fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ]
>> Signed-off-by: Joonwon Kang <joonwonkang@google.com>
>> ---
>> drivers/mailbox/mailbox.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>
>What kernel tree(s) is this for?
Sorry, please ignore this patch. I have specified the proper kernel tree
in other patches.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-04 11:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 7:30 [PATCH] mailbox: Prevent out-of-bounds access in of_mbox_index_xlate() Joonwon Kang
2026-03-04 9:10 ` Greg KH
2026-03-04 11:01 ` Joonwon Kang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox