[PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate()
From: Lee Jones
Date: Thu Dec 03 2026 - 03:28:25 EST
ti_msgmgr_of_xlate() stores u32 Device Tree phandle arguments in signed
int variables req_qid and req_pid. On Secure Proxy instances, a
malformed DT argument greater than INT_MAX becomes negative, bypasses
the upper-bound check, and indexes inst->qinsts[req_pid] out of bounds
before the start of the array.
Use u32 for req_qid and req_pid, validate req_pid against
inst->num_valid_queues, and update the error format specifiers to %u.
Fixes: a2b79838b891 ("mailbox: ti-msgmgr: Add support for Secure Proxy")
Closes: https://sashiko.dev/#/bug/linux-bc6deda6-efad-4f90-b213-85bb3fd21eca
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
Cc: Beleswar Padhi <b-padhi@xxxxxx>
Cc: Jassi Brar <jassisinghbrar@xxxxxxxxx>
Cc: Nishanth Menon <nm@xxxxxx>
drivers/mailbox/ti-msgmgr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c
index 2079996092f5..d2d917b53c94 100644
--- a/drivers/mailbox/ti-msgmgr.c
+++ b/drivers/mailbox/ti-msgmgr.c
@@ -596,7 +596,7 @@ static struct mbox_chan *ti_msgmgr_of_xlate(struct mbox_controller *mbox,
const struct of_phandle_args *p)
{
struct ti_msgmgr_inst *inst;
- int req_qid, req_pid;
+ u32 req_qid, req_pid;
struct ti_queue_inst *qinst;
const struct ti_msgmgr_desc *d;
int i, ncells;
@@ -625,7 +625,7 @@ static struct mbox_chan *ti_msgmgr_of_xlate(struct mbox_controller *mbox,
}
if (d->is_sproxy) {
- if (req_pid >= d->num_valid_queues)
+ if (req_pid >= inst->num_valid_queues)
goto err;
qinst = &inst->qinsts[req_pid];
return qinst->chan;
@@ -638,7 +638,7 @@ static struct mbox_chan *ti_msgmgr_of_xlate(struct mbox_controller *mbox,
}
err:
- dev_err(inst->dev, "Queue ID %d, Proxy ID %d is wrong on %pOFn\n",
+ dev_err(inst->dev, "Queue ID %u, Proxy ID %u is wrong on %pOFn\n",
req_qid, req_pid, p->np);
return ERR_PTR(-ENOENT);
}
--
2.56.1.911.g883d8bcb20-goog