mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
Subsystems (2)
PATCH 1/1 mailbox: Prevent out-of-bounds access in of_mbox_index_xlate()
[ 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.
[ changed sp->nargs to sp->args_count in the code and fw_mbox_index_xlate() to of_mbox_index_xlate() in the commit message. ]
--- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mailbox/mailbox.c +2 -4
@@ -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 ]]; }/**
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Greg KH
maintainerQuoted 12 lines · Joonwon Kang
[ Upstream commit
fcd7f96c783626c07ee3ed75fa3739a8a2052310]Although it is guided that
#mbox-cellsmust 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 providefw_xlateandof_xlatefunction 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.Signed-off-by Joonwon Kang <[email protected]>Signed-off-by Jassi Brar <[email protected]>
Quoted 6 lines
[ changed
sp->nargstosp->args_countin the code andfw_mbox_index_xlate()toof_mbox_index_xlate()in the commit message. ]Signed-off-by Joonwon Kang <[email protected]>--- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
What kernel tree(s) is this for?
Quoted 19 lines
Quoted 12 lines
[ Upstream commit
fcd7f96c783626c07ee3ed75fa3739a8a2052310]Although it is guided that
#mbox-cellsmust 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 providefw_xlateandof_xlatefunction 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.Signed-off-by Joonwon Kang <[email protected]>Signed-off-by Jassi Brar <[email protected]>Quoted 6 lines
[ changed
sp->nargstosp->args_countin the code andfw_mbox_index_xlate()toof_mbox_index_xlate()in the commit message. ]Signed-off-by Joonwon Kang <[email protected]>--- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Quoted 1 line
What kernel tree(s) is this for?
Sorry, please ignore this patch. I have specified the proper kernel tree in other patches.
Thanks.