mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko
@ 2026-12-03  8:28 Lee Jones
  2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, Albert Ou, Alexandre Ghiti, Anup Patel,
	Beleswar Padhi, Bjorn Andersson, Chen-Yu Tsai, Huang Yiwei,
	Jassi Brar, Jernej Skrabec, Kumar Gutta, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-sunxi, Manivannan Sadhasivam,
	Nishanth Menon, Palmer Dabbelt, Pan Chuang, Paul Walmsley,
	Philipp Zabel, Raghavendra Rao Ananta, Rahul Pathak, Rob Rice,
	Samuel Holland, Sudeep Holla, Thierry Reding

This series fixes 10 Critical and High issues across mailbox controller
drivers (qcom-ipcc, ti-msgmgr, riscv-sbi-mpxy, bcm-pdc, sun6i-msgbox,
and arm_mhu_db), covering uninitialised phandle puts, signed index and
shmem out-of-bounds accesses, per-CPU hardirq races, DMA pool and IRQ
domain teardown use-after-frees, IRQ/clock/shutdown synchronisation
races, premature controller registration, and silent queue-error
returns.

These issues were reported by Sashiko.

Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Anup Patel <apatel@ventanamicro.com>
Cc: Beleswar Padhi <b-padhi@ti.com>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Huang Yiwei <quic_hyiwei@quicinc.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Kumar Gutta <vnkgutta@codeaurora.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Pan Chuang <panchuang@vivo.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Raghavendra Rao Ananta <rananta@codeaurora.org>
Cc: Rahul Pathak <rahul@summations.net>
Cc: Rob Rice <rob.rice@broadcom.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Sudeep Holla <sudeep.holla@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>

Lee Jones (10):
  mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure
  mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate()
  mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave
  mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers
  mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA
    pools
  mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR
    use-after-free
  mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown
  mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown
  mailbox: arm_mhu_db: Initialise channel registers before controller
    registration
  mailbox: ti-msgmgr: Return -EIO on queue error in
    ti_msgmgr_send_data()

 drivers/mailbox/arm_mhu_db.c          |  19 ++--
 drivers/mailbox/bcm-pdc-mailbox.c     |   4 +-
 drivers/mailbox/qcom-ipcc.c           |  33 ++++---
 drivers/mailbox/riscv-sbi-mpxy-mbox.c | 121 ++++++++++++++------------
 drivers/mailbox/sun6i-msgbox.c        |  25 ++++--
 drivers/mailbox/ti-msgmgr.c           |   8 +-
 6 files changed, 118 insertions(+), 92 deletions(-)

-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03 10:38   ` Konrad Dybcio
  2026-12-03  8:28 ` [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate() Lee Jones
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Huang Yiwei, Jassi Brar, Kumar Gutta,
	linux-arm-msm, Manivannan Sadhasivam

qcom_ipcc_setup_mbox() declares curr_ph on the stack without
initialising it and unconditionally calls of_node_put(curr_ph.np)
immediately after of_parse_phandle_with_args(), before checking whether
the call succeeded.  If of_parse_phandle_with_args() fails on the first
iteration, of_node_put() dereferences an uninitialised stack pointer;
on subsequent iterations it drops the reference to the previous node a
second time.

Skip the remainder of the loop iteration when
of_parse_phandle_with_args() returns an error, and only release
curr_ph.np on success.

Fixes: e9d50e4b4d04 ("mailbox: qcom-ipcc: Dynamic alloc for channel arrangement")
Closes: https://sashiko.dev/#/bug/linux-2052db5b-c6e1-4da3-aab4-7612dc67c78b
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Huang Yiwei <quic_hyiwei@quicinc.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Kumar Gutta <vnkgutta@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: Manivannan Sadhasivam <mani@kernel.org>

 drivers/mailbox/qcom-ipcc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/qcom-ipcc.c b/drivers/mailbox/qcom-ipcc.c
index bb54295e03ce..19fea341bd12 100644
--- a/drivers/mailbox/qcom-ipcc.c
+++ b/drivers/mailbox/qcom-ipcc.c
@@ -239,9 +239,12 @@ static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc,
 		for (j = 0; j < i; j++) {
 			ret = of_parse_phandle_with_args(client_dn, "mboxes",
 						"#mbox-cells", j, &curr_ph);
-			of_node_put(curr_ph.np);
-			if (!ret && curr_ph.np == controller_dn)
+			if (ret)
+				continue;
+
+			if (curr_ph.np == controller_dn)
 				ipcc->num_chans++;
+			of_node_put(curr_ph.np);
 		}
 	}
 
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate()
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
  2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03  8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee; +Cc: linux-kernel, stable, Beleswar Padhi, Jassi Brar, Nishanth Menon

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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Beleswar Padhi <b-padhi@ti.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Nishanth Menon <nm@ti.com>

 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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
  2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
  2026-12-03  8:28 ` [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate() Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03 14:32   ` Rahul Pathak
  2026-12-03  8:28 ` [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers Lee Jones
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Albert Ou, Alexandre Ghiti, Anup Patel,
	Jassi Brar, linux-riscv, Palmer Dabbelt, Paul Walmsley,
	Rahul Pathak

The SBI MPXY helpers evaluate this_cpu_ptr(&mpxy_local) before calling
get_cpu(), allowing CPU migration between computing the per-CPU pointer
and disabling preemption.  They also leave local interrupts enabled
while using the per-CPU shared memory buffer, allowing a hardirq caller
(such as mbox_send_message() or mpxy_mbox_msi_write()) to clobber the
shared memory buffer mid-operation.

Use guard(irqsave)() across all per-CPU shared memory helpers and fetch
this_cpu_ptr(&mpxy_local) inside the IRQ-disabled section.

Fixes: bf3022a4eb11 ("mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-d2c1eefe-4777-4ad6-94c5-504e347f3add
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Anup Patel <apatel@ventanamicro.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: linux-riscv@lists.infradead.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Rahul Pathak <rahul@summations.net>

 drivers/mailbox/riscv-sbi-mpxy-mbox.c | 114 +++++++++++++-------------
 1 file changed, 59 insertions(+), 55 deletions(-)

diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
index 4ebce35a8b6c..90b1972a42ea 100644
--- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c
+++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
@@ -6,10 +6,12 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/cleanup.h>
 #include <linux/cpu.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/irqchip/riscv-imsic.h>
+#include <linux/irqflags.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox/riscv-rpmi-message.h>
 #include <linux/minmax.h>
@@ -127,52 +129,57 @@ static bool mpxy_shmem_init_done;
 
 static int mpxy_get_channel_count(u32 *channel_count)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
-	struct sbi_mpxy_channel_ids_data *sdata = mpxy->shmem;
+	struct sbi_mpxy_channel_ids_data *sdata;
+	struct mpxy_local *mpxy;
 	u32 remaining, returned;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!channel_count)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	/* Get the remaining and returned fields to calculate total */
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS,
 			 0, 0, 0, 0, 0, 0);
 	if (sret.error)
-		goto err_put_cpu;
+		return sbi_err_map_linux_errno(sret.error);
 
+	sdata = mpxy->shmem;
 	remaining = le32_to_cpu(sdata->remaining);
 	returned = le32_to_cpu(sdata->returned);
 	*channel_count = remaining + returned;
 
-err_put_cpu:
-	put_cpu();
-	return sbi_err_map_linux_errno(sret.error);
+	return 0;
 }
 
 static int mpxy_get_channel_ids(u32 channel_count, u32 *channel_ids)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
-	struct sbi_mpxy_channel_ids_data *sdata = mpxy->shmem;
 	u32 remaining, returned, count, start_index = 0;
+	struct sbi_mpxy_channel_ids_data *sdata;
+	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!channel_count || !channel_ids)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
+
+	sdata = mpxy->shmem;
 
 	do {
 		sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_CHANNEL_IDS,
 				 start_index, 0, 0, 0, 0, 0);
 		if (sret.error)
-			goto err_put_cpu;
+			return sbi_err_map_linux_errno(sret.error);
 
 		remaining = le32_to_cpu(sdata->remaining);
 		returned = le32_to_cpu(sdata->returned);
@@ -183,54 +190,53 @@ static int mpxy_get_channel_ids(u32 channel_count, u32 *channel_ids)
 		start_index += count;
 	} while (remaining && start_index < channel_count);
 
-err_put_cpu:
-	put_cpu();
-	return sbi_err_map_linux_errno(sret.error);
+	return 0;
 }
 
 static int mpxy_read_attrs(u32 channel_id, u32 base_attrid, u32 attr_count,
 			   u32 *attrs_buf)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
+	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!attr_count || !attrs_buf)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_READ_ATTRS,
 			 channel_id, base_attrid, attr_count, 0, 0, 0);
 	if (sret.error)
-		goto err_put_cpu;
+		return sbi_err_map_linux_errno(sret.error);
 
 	memcpy_from_le32(attrs_buf, (__le32 *)mpxy->shmem, attr_count);
 
-err_put_cpu:
-	put_cpu();
-	return sbi_err_map_linux_errno(sret.error);
+	return 0;
 }
 
 static int mpxy_write_attrs(u32 channel_id, u32 base_attrid, u32 attr_count,
 			    u32 *attrs_buf)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
+	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!attr_count || !attrs_buf)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	memcpy_to_le32((__le32 *)mpxy->shmem, attrs_buf, attr_count);
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_WRITE_ATTRS,
 			 channel_id, base_attrid, attr_count, 0, 0, 0);
 
-	put_cpu();
 	return sbi_err_map_linux_errno(sret.error);
 }
 
@@ -239,16 +245,18 @@ static int mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
 				       void *rx, unsigned long max_rx_len,
 				       unsigned long *rx_len)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
+	struct mpxy_local *mpxy;
 	unsigned long rx_bytes;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!tx && tx_len)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	/* Message protocols allowed to have no data in messages */
 	if (tx_len)
@@ -258,32 +266,31 @@ static int mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
 			 channel_id, msg_id, tx_len, 0, 0, 0);
 	if (rx && !sret.error) {
 		rx_bytes = sret.value;
-		if (rx_bytes > max_rx_len) {
-			put_cpu();
+		if (rx_bytes > max_rx_len)
 			return -ENOSPC;
-		}
 
 		memcpy(rx, mpxy->shmem, rx_bytes);
 		if (rx_len)
 			*rx_len = rx_bytes;
 	}
 
-	put_cpu();
 	return sbi_err_map_linux_errno(sret.error);
 }
 
 static int mpxy_send_message_without_resp(u32 channel_id, u32 msg_id,
 					  void *tx, unsigned long tx_len)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
+	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!tx && tx_len)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	/* Message protocols allowed to have no data in messages */
 	if (tx_len)
@@ -292,7 +299,6 @@ static int mpxy_send_message_without_resp(u32 channel_id, u32 msg_id,
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SEND_MSG_WITHOUT_RESP,
 			 channel_id, msg_id, tx_len, 0, 0, 0);
 
-	put_cpu();
 	return sbi_err_map_linux_errno(sret.error);
 }
 
@@ -300,32 +306,30 @@ static int mpxy_get_notifications(u32 channel_id,
 				  struct sbi_mpxy_notification_data *notif_data,
 				  unsigned long *events_data_len)
 {
-	struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
+	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!mpxy->shmem_active)
-		return -ENODEV;
 	if (!notif_data || !events_data_len)
 		return -EINVAL;
 
-	get_cpu();
+	guard(irqsave)();
+
+	mpxy = this_cpu_ptr(&mpxy_local);
+	if (!mpxy->shmem_active)
+		return -ENODEV;
 
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_GET_NOTIFICATION_EVENTS,
 			 channel_id, 0, 0, 0, 0, 0);
 	if (sret.error)
-		goto err_put_cpu;
+		return sbi_err_map_linux_errno(sret.error);
 	if (sret.value < 0 || mpxy_shmem_size < sizeof(*notif_data) ||
-	    sret.value > mpxy_shmem_size - sizeof(*notif_data)) {
-		put_cpu();
+	    sret.value > mpxy_shmem_size - sizeof(*notif_data))
 		return -EOVERFLOW;
-	}
 
 	memcpy(notif_data, mpxy->shmem, sret.value + sizeof(*notif_data));
 	*events_data_len = sret.value;
 
-err_put_cpu:
-	put_cpu();
-	return sbi_err_map_linux_errno(sret.error);
+	return 0;
 }
 
 static int mpxy_get_shmem_size(unsigned long *shmem_size)
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (2 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03  8:28 ` [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools Lee Jones
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Albert Ou, Alexandre Ghiti, Anup Patel,
	Jassi Brar, linux-riscv, Palmer Dabbelt, Paul Walmsley,
	Rahul Pathak

Neither mpxy_send_message_with_resp() nor
mpxy_send_message_without_resp() verifies that tx_len fits within
mpxy_shmem_size before copying into mpxy->shmem.  In addition,
mpxy_send_message_with_resp() checks rx_bytes against max_rx_len but
never verifies that firmware's returned sret.value is non-negative and
within mpxy_shmem_size before copying out of mpxy->shmem.

Reject tx_len > mpxy_shmem_size with -EINVAL in both send helpers, and
reject negative or out-of-bounds sret.value with -EOVERFLOW in
mpxy_send_message_with_resp().

Fixes: bf3022a4eb11 ("mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-3c3c0397-a448-41ba-bb19-e7f98ccf265a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Anup Patel <apatel@ventanamicro.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: linux-riscv@lists.infradead.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Rahul Pathak <rahul@summations.net>

 drivers/mailbox/riscv-sbi-mpxy-mbox.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
index 90b1972a42ea..8f0af2e3eb94 100644
--- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c
+++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
@@ -249,7 +249,7 @@ static int mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
 	unsigned long rx_bytes;
 	struct sbiret sret;
 
-	if (!tx && tx_len)
+	if ((!tx && tx_len) || tx_len > mpxy_shmem_size)
 		return -EINVAL;
 
 	guard(irqsave)();
@@ -265,6 +265,9 @@ static int mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
 	sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SEND_MSG_WITH_RESP,
 			 channel_id, msg_id, tx_len, 0, 0, 0);
 	if (rx && !sret.error) {
+		if (sret.value < 0 || (unsigned long)sret.value > mpxy_shmem_size)
+			return -EOVERFLOW;
+
 		rx_bytes = sret.value;
 		if (rx_bytes > max_rx_len)
 			return -ENOSPC;
@@ -283,7 +286,7 @@ static int mpxy_send_message_without_resp(u32 channel_id, u32 msg_id,
 	struct mpxy_local *mpxy;
 	struct sbiret sret;
 
-	if (!tx && tx_len)
+	if ((!tx && tx_len) || tx_len > mpxy_shmem_size)
 		return -EINVAL;
 
 	guard(irqsave)();
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (3 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03  8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Jassi Brar, Pan Chuang, Rob Rice, Thierry Reding

pdc_mb_init() registers the mailbox controller with
devm_mbox_controller_register(), whereas pdc_remove() manually destroys
pdcs->rx_buf_pool and pdcs->ring_pool.  Because devres teardown runs
after pdc_remove() returns, mbox_controller_unregister() invokes
pdc_shutdown() and pdc_ring_free() on already-destroyed DMA pools, and
concurrent sends in pdc_rx_list_init() can allocate from the destroyed
rx_buf_pool.

Register the mailbox controller with mbox_controller_register() and
explicitly call mbox_controller_unregister() in pdc_remove() after
disabling the hardware and before destroying the DMA pools.

Fixes: 6267ee6afae0 ("mailbox: bcm-pdc: Use device-managed registration API")
Closes: https://sashiko.dev/#/bug/linux-8e397ec0-b0b5-4a26-b226-828f8b4bad77
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Pan Chuang <panchuang@vivo.com>
Cc: Rob Rice <rob.rice@broadcom.com>
Cc: Thierry Reding <treding@nvidia.com>

 drivers/mailbox/bcm-pdc-mailbox.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c
index 6fcc4002ad4f..159c2ab17a9d 100644
--- a/drivers/mailbox/bcm-pdc-mailbox.c
+++ b/drivers/mailbox/bcm-pdc-mailbox.c
@@ -1450,7 +1450,7 @@ static int pdc_mb_init(struct pdc_state *pdcs)
 		mbc->chans[chan_index].con_priv = pdcs;
 
 	/* Register mailbox controller */
-	err = devm_mbox_controller_register(dev, mbc);
+	err = mbox_controller_register(mbc);
 	if (err) {
 		dev_crit(dev,
 			 "Failed to register PDC mailbox controller. Error %d.",
@@ -1609,6 +1609,8 @@ static void pdc_remove(struct platform_device *pdev)
 
 	pdc_hw_disable(pdcs);
 
+	mbox_controller_unregister(&pdcs->mbc);
+
 	dma_pool_destroy(pdcs->rx_buf_pool);
 	dma_pool_destroy(pdcs->ring_pool);
 }
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (4 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03 10:39   ` Konrad Dybcio
  2026-12-03  8:28 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Bjorn Andersson, Jassi Brar, Kumar Gutta,
	linux-arm-msm, Manivannan Sadhasivam, Raghavendra Rao Ananta

qcom_ipcc_probe() registers qcom_ipcc_irq_fn() using devm_request_irq(),
but qcom_ipcc_remove() manually removes ipcc->irq_domain before devres
frees the interrupt.  If an interrupt fires during unbind,
qcom_ipcc_irq_fn() dereferences the freed IRQ domain.

Register irq_domain_remove() via devm_add_action_or_reset() immediately
after irq_domain_create_tree() and drop qcom_ipcc_remove() so devres
tears down the IRQ, mailbox controller, and IRQ domain in strict reverse
order.

Fixes: fa74a0257f45 ("mailbox: Add support for Qualcomm IPCC")
Closes: https://sashiko.dev/#/bug/linux-f9f9c7a3-ce00-42b7-9a78-843c2f3712eb
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Kumar Gutta <vnkgutta@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Raghavendra Rao Ananta <rananta@codeaurora.org>

 drivers/mailbox/qcom-ipcc.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/mailbox/qcom-ipcc.c b/drivers/mailbox/qcom-ipcc.c
index 19fea341bd12..7481f88527d2 100644
--- a/drivers/mailbox/qcom-ipcc.c
+++ b/drivers/mailbox/qcom-ipcc.c
@@ -287,6 +287,11 @@ static int qcom_ipcc_pm_resume(struct device *dev)
 	return 0;
 }
 
+static void qcom_ipcc_irq_domain_remove(void *data)
+{
+	irq_domain_remove(data);
+}
+
 static int qcom_ipcc_probe(struct platform_device *pdev)
 {
 	struct qcom_ipcc *ipcc;
@@ -324,31 +329,23 @@ static int qcom_ipcc_probe(struct platform_device *pdev)
 	if (!ipcc->irq_domain)
 		return -ENOMEM;
 
+	ret = devm_add_action_or_reset(&pdev->dev, qcom_ipcc_irq_domain_remove, ipcc->irq_domain);
+	if (ret)
+		return ret;
+
 	ret = qcom_ipcc_setup_mbox(ipcc, pdev->dev.of_node);
 	if (ret)
-		goto err_mbox;
+		return ret;
 
 	ret = devm_request_irq(&pdev->dev, ipcc->irq, qcom_ipcc_irq_fn,
 			       IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND |
 			       IRQF_NO_THREAD, dev_name(&pdev->dev), ipcc);
 	if (ret < 0)
-		goto err_mbox;
+		return ret;
 
 	platform_set_drvdata(pdev, ipcc);
 
 	return 0;
-
-err_mbox:
-	irq_domain_remove(ipcc->irq_domain);
-
-	return ret;
-}
-
-static void qcom_ipcc_remove(struct platform_device *pdev)
-{
-	struct qcom_ipcc *ipcc = platform_get_drvdata(pdev);
-
-	irq_domain_remove(ipcc->irq_domain);
 }
 
 static const struct of_device_id qcom_ipcc_of_match[] = {
@@ -363,7 +360,6 @@ static const struct dev_pm_ops qcom_ipcc_dev_pm_ops = {
 
 static struct platform_driver qcom_ipcc_driver = {
 	.probe = qcom_ipcc_probe,
-	.remove = qcom_ipcc_remove,
 	.driver = {
 		.name = "qcom-ipcc",
 		.of_match_table = qcom_ipcc_of_match,
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (5 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03 13:43   ` Chen-Yu Tsai
  2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Chen-Yu Tsai, Jassi Brar, Jernej Skrabec,
	linux-arm-kernel, linux-sunxi, Philipp Zabel, Samuel Holland

sun6i_msgbox_probe() requests the interrupt using devm_request_irq()
before initialising mbox->controller and mbox->lock, while
sun6i_msgbox_remove() manually calls mbox_controller_unregister() and
clk_disable_unprepare() before devres frees the IRQ.  An interrupt
arriving during probe failure or device removal can access unclocked
MMIO registers or freed controller data in sun6i_msgbox_irq().

Retrieve the IRQ via platform_get_irq() and register it with
request_irq() after initialising mbox->controller and mbox->lock, then
explicitly call free_irq() before disabling the clock in both the probe
error path and sun6i_msgbox_remove().

Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-b10c9846-995f-40c3-a18c-97b9cb0d0611
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Samuel Holland <samuel@sholland.org>

 drivers/mailbox/sun6i-msgbox.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c
index 1cbc4d478beb..4c5669035420 100644
--- a/drivers/mailbox/sun6i-msgbox.c
+++ b/drivers/mailbox/sun6i-msgbox.c
@@ -12,7 +12,6 @@
 #include <linux/mailbox_controller.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
 #include <linux/spinlock.h>
@@ -48,6 +47,7 @@ struct sun6i_msgbox {
 	struct clk *clk;
 	spinlock_t lock;
 	void __iomem *regs;
+	int irq;
 };
 
 static bool sun6i_msgbox_last_tx_done(struct mbox_chan *chan);
@@ -255,11 +255,6 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	/* Disable all IRQs for this end of the msgbox. */
 	writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
 
-	ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
-			       sun6i_msgbox_irq, 0, dev_name(dev), mbox);
-	if (ret)
-		goto err_disable_unprepare;
-
 	mbox->controller.dev           = dev;
 	mbox->controller.ops           = &sun6i_msgbox_chan_ops;
 	mbox->controller.chans         = chans;
@@ -271,14 +266,26 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	spin_lock_init(&mbox->lock);
 	platform_set_drvdata(pdev, mbox);
 
+	mbox->irq = platform_get_irq(pdev, 0);
+	if (mbox->irq < 0) {
+		ret = mbox->irq;
+		goto err_disable_unprepare;
+	}
+
+	ret = request_irq(mbox->irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
+	if (ret)
+		goto err_disable_unprepare;
+
 	ret = mbox_controller_register(&mbox->controller);
 	if (ret) {
 		dev_err(dev, "Failed to register controller: %d\n", ret);
-		goto err_disable_unprepare;
+		goto err_free_irq;
 	}
 
 	return 0;
 
+err_free_irq:
+	free_irq(mbox->irq, mbox);
 err_disable_unprepare:
 	clk_disable_unprepare(mbox->clk);
 
@@ -290,6 +297,7 @@ static void sun6i_msgbox_remove(struct platform_device *pdev)
 	struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
 
 	mbox_controller_unregister(&mbox->controller);
+	free_irq(mbox->irq, mbox);
 	/* See the comment in sun6i_msgbox_probe about the reset line. */
 	clk_disable_unprepare(mbox->clk);
 }
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (6 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03 13:49   ` Chen-Yu Tsai
  2026-12-03  8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
  2026-12-03  8:28 ` [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data() Lee Jones
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Chen-Yu Tsai, Jassi Brar, Jernej Skrabec,
	linux-arm-kernel, linux-sunxi, Philipp Zabel, Samuel Holland

sun6i_msgbox_shutdown() disables the channel receive interrupt and
immediately flushes the receive FIFO and returns to mbox_free_channel()
without waiting for an already-executing sun6i_msgbox_irq() on another
CPU.  Both contexts can concurrently read MSG_DATA_REG(n) and underflow
the FIFO, and the ISR can invoke mbox_chan_received_data() after the
client is torn down.

Call synchronize_irq(mbox->irq) after disabling the channel receive
interrupt and before flushing the FIFO.

Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
Closes: https://sashiko.dev/#/bug/linux-bdac10dc-aab3-41b2-a13a-eb012e1fd2f9
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-sunxi@lists.linux.dev
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Samuel Holland <samuel@sholland.org>

 drivers/mailbox/sun6i-msgbox.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c
index 4c5669035420..0d941b2bda6a 100644
--- a/drivers/mailbox/sun6i-msgbox.c
+++ b/drivers/mailbox/sun6i-msgbox.c
@@ -148,6 +148,9 @@ static void sun6i_msgbox_shutdown(struct mbox_chan *chan)
 		       mbox->regs + LOCAL_IRQ_EN_REG);
 		spin_unlock(&mbox->lock);
 
+		/* Wait for any in-flight ISR to finish before flushing. */
+		synchronize_irq(mbox->irq);
+
 		/* Attempt to flush the FIFO until the IRQ is cleared. */
 		do {
 			while (sun6i_msgbox_peek_data(chan))
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (7 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03  9:40   ` Sudeep Holla
  2026-12-03  8:28 ` [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data() Lee Jones
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee; +Cc: linux-kernel, stable, Jassi Brar, Sudeep Holla

mhu_db_probe() registers the mailbox controller via
devm_mbox_controller_register() before populating mhu->mlink[].irq,
rx_reg, and tx_reg.  A client binding immediately after controller
registration can therefore dereference NULL rx_reg or tx_reg pointers
in mhu_db_startup() or mhu_db_send_data().

Populate mhu->mlink[].irq, rx_reg, and tx_reg before calling
devm_mbox_controller_register(), while keeping
devm_request_threaded_irq() after registration so devres continues to
free all IRQs before unregistering the controller on unbind or probe
failure.

Fixes: 7002ca237b21 ("mailbox: arm_mhu: Add ARM MHU doorbell driver")
Closes: https://sashiko.dev/#/bug/linux-2f1b809f-5c0c-4cd3-b99e-53265de37a3f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Sudeep Holla <sudeep.holla@kernel.org>

 drivers/mailbox/arm_mhu_db.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/mailbox/arm_mhu_db.c b/drivers/mailbox/arm_mhu_db.c
index 9f1c7bcfdcb4..c825f4ec43cf 100644
--- a/drivers/mailbox/arm_mhu_db.c
+++ b/drivers/mailbox/arm_mhu_db.c
@@ -297,12 +297,6 @@ static int mhu_db_probe(struct amba_device *adev, const struct amba_id *id)
 
 	mhu->mbox.ops = &mhu_db_ops;
 
-	err = devm_mbox_controller_register(dev, &mhu->mbox);
-	if (err) {
-		dev_err(dev, "Failed to register mailboxes %d\n", err);
-		return err;
-	}
-
 	for (i = 0; i < MHU_CHANS; i++) {
 		int irq = mhu->mlink[i].irq = adev->irq[i];
 
@@ -313,6 +307,19 @@ static int mhu_db_probe(struct amba_device *adev, const struct amba_id *id)
 
 		mhu->mlink[i].rx_reg = mhu->base + mhu_reg[i];
 		mhu->mlink[i].tx_reg = mhu->mlink[i].rx_reg + TX_REG_OFFSET;
+	}
+
+	err = devm_mbox_controller_register(dev, &mhu->mbox);
+	if (err) {
+		dev_err(dev, "Failed to register mailboxes %d\n", err);
+		return err;
+	}
+
+	for (i = 0; i < MHU_CHANS; i++) {
+		int irq = mhu->mlink[i].irq;
+
+		if (irq <= 0)
+			continue;
 
 		err = devm_request_threaded_irq(dev, irq, NULL,
 						mhu_db_mbox_rx_handler,
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data()
  2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (8 preceding siblings ...)
  2026-12-03  8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
@ 2026-12-03  8:28 ` Lee Jones
  9 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2026-12-03  8:28 UTC (permalink / raw)
  To: lee; +Cc: linux-kernel, stable, Beleswar Padhi, Jassi Brar, Nishanth Menon

ti_msgmgr_send_data() returns int, yet on a queue error it executes
return false, which evaluates to 0.  The mailbox core therefore treats
the failed submission as successful, marks the message active, and
stalls the channel.

Return -EIO when ti_msgmgr_queue_is_error() reports a queue error.

Fixes: a2b79838b891 ("mailbox: ti-msgmgr: Add support for Secure Proxy")
Closes: https://sashiko.dev/#/bug/linux-3733bc16-e5d3-42b3-b348-59454a5c7caf
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

Cc: Beleswar Padhi <b-padhi@ti.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Cc: Nishanth Menon <nm@ti.com>

 drivers/mailbox/ti-msgmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c
index d2d917b53c94..531c027edcf7 100644
--- a/drivers/mailbox/ti-msgmgr.c
+++ b/drivers/mailbox/ti-msgmgr.c
@@ -408,7 +408,7 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)
 
 	if (ti_msgmgr_queue_is_error(desc, qinst)) {
 		dev_err(dev, "Error on channel %s\n", qinst->name);
-		return false;
+		return -EIO;
 	}
 
 	if (desc->max_message_size < message->len) {
-- 
2.56.1.911.g883d8bcb20-goog


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration
  2026-12-03  8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
@ 2026-12-03  9:40   ` Sudeep Holla
  0 siblings, 0 replies; 17+ messages in thread
From: Sudeep Holla @ 2026-12-03  9:40 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, stable, Sudeep Holla, Jassi Brar

On Thu, Dec 03, 2026 at 08:28:09AM +0000, Lee Jones wrote:
> mhu_db_probe() registers the mailbox controller via
> devm_mbox_controller_register() before populating mhu->mlink[].irq,
> rx_reg, and tx_reg.  A client binding immediately after controller
> registration can therefore dereference NULL rx_reg or tx_reg pointers
> in mhu_db_startup() or mhu_db_send_data().
> 
> Populate mhu->mlink[].irq, rx_reg, and tx_reg before calling
> devm_mbox_controller_register(), while keeping
> devm_request_threaded_irq() after registration so devres continues to
> free all IRQs before unregistering the controller on unbind or probe
> failure.
> 

Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure
  2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
@ 2026-12-03 10:38   ` Konrad Dybcio
  0 siblings, 0 replies; 17+ messages in thread
From: Konrad Dybcio @ 2026-12-03 10:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, stable, Huang Yiwei, Jassi Brar, Kumar Gutta,
	linux-arm-msm, Manivannan Sadhasivam

On 12/3/26 9:28 AM, Lee Jones wrote:
> qcom_ipcc_setup_mbox() declares curr_ph on the stack without
> initialising it and unconditionally calls of_node_put(curr_ph.np)
> immediately after of_parse_phandle_with_args(), before checking whether
> the call succeeded.  If of_parse_phandle_with_args() fails on the first
> iteration, of_node_put() dereferences an uninitialised stack pointer;
> on subsequent iterations it drops the reference to the previous node a
> second time.
> 
> Skip the remainder of the loop iteration when
> of_parse_phandle_with_args() returns an error, and only release
> curr_ph.np on success.
> 
> Fixes: e9d50e4b4d04 ("mailbox: qcom-ipcc: Dynamic alloc for channel arrangement")
> Closes: https://sashiko.dev/#/bug/linux-2052db5b-c6e1-4da3-aab4-7612dc67c78b
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free
  2026-12-03  8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
@ 2026-12-03 10:39   ` Konrad Dybcio
  0 siblings, 0 replies; 17+ messages in thread
From: Konrad Dybcio @ 2026-12-03 10:39 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, stable, Bjorn Andersson, Jassi Brar, Kumar Gutta,
	linux-arm-msm, Manivannan Sadhasivam, Raghavendra Rao Ananta

On 12/3/26 9:28 AM, Lee Jones wrote:
> qcom_ipcc_probe() registers qcom_ipcc_irq_fn() using devm_request_irq(),
> but qcom_ipcc_remove() manually removes ipcc->irq_domain before devres
> frees the interrupt.  If an interrupt fires during unbind,
> qcom_ipcc_irq_fn() dereferences the freed IRQ domain.
> 
> Register irq_domain_remove() via devm_add_action_or_reset() immediately
> after irq_domain_create_tree() and drop qcom_ipcc_remove() so devres
> tears down the IRQ, mailbox controller, and IRQ domain in strict reverse
> order.
> 
> Fixes: fa74a0257f45 ("mailbox: Add support for Qualcomm IPCC")
> Closes: https://sashiko.dev/#/bug/linux-f9f9c7a3-ce00-42b7-9a78-843c2f3712eb
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown
  2026-12-03  8:28 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
@ 2026-12-03 13:43   ` Chen-Yu Tsai
  0 siblings, 0 replies; 17+ messages in thread
From: Chen-Yu Tsai @ 2026-12-03 13:43 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, stable, Jassi Brar, Jernej Skrabec,
	linux-arm-kernel, linux-sunxi, Philipp Zabel, Samuel Holland

On Thu, Dec 3, 2026 at 5:28 PM Lee Jones <lee@kernel.org> wrote:
>
> sun6i_msgbox_probe() requests the interrupt using devm_request_irq()
> before initialising mbox->controller and mbox->lock, while
> sun6i_msgbox_remove() manually calls mbox_controller_unregister() and
> clk_disable_unprepare() before devres frees the IRQ.  An interrupt
> arriving during probe failure or device removal can access unclocked
> MMIO registers or freed controller data in sun6i_msgbox_irq().
>
> Retrieve the IRQ via platform_get_irq() and register it with
> request_irq() after initialising mbox->controller and mbox->lock, then
> explicitly call free_irq() before disabling the clock in both the probe
> error path and sun6i_msgbox_remove().
>
> Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
> Closes: https://sashiko.dev/#/bug/linux-b10c9846-995f-40c3-a18c-97b9cb0d0611
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown
  2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
@ 2026-12-03 13:49   ` Chen-Yu Tsai
  0 siblings, 0 replies; 17+ messages in thread
From: Chen-Yu Tsai @ 2026-12-03 13:49 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, stable, Jassi Brar, Jernej Skrabec,
	linux-arm-kernel, linux-sunxi, Philipp Zabel, Samuel Holland

On Thu, Dec 3, 2026 at 5:28 PM Lee Jones <lee@kernel.org> wrote:
>
> sun6i_msgbox_shutdown() disables the channel receive interrupt and
> immediately flushes the receive FIFO and returns to mbox_free_channel()
> without waiting for an already-executing sun6i_msgbox_irq() on another
> CPU.  Both contexts can concurrently read MSG_DATA_REG(n) and underflow
> the FIFO, and the ISR can invoke mbox_chan_received_data() after the
> client is torn down.
>
> Call synchronize_irq(mbox->irq) after disabling the channel receive
> interrupt and before flushing the FIFO.
>
> Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver")
> Closes: https://sashiko.dev/#/bug/linux-bdac10dc-aab3-41b2-a13a-eb012e1fd2f9
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave
  2026-12-03  8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
@ 2026-12-03 14:32   ` Rahul Pathak
  0 siblings, 0 replies; 17+ messages in thread
From: Rahul Pathak @ 2026-12-03 14:32 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, stable, Albert Ou, Alexandre Ghiti, Anup Patel,
	Jassi Brar, linux-riscv, Palmer Dabbelt, Paul Walmsley,
	Rahul Pathak

On Thu, Dec 3, 2026 at 1:59 PM Lee Jones <lee@kernel.org> wrote:
>
> The SBI MPXY helpers evaluate this_cpu_ptr(&mpxy_local) before calling
> get_cpu(), allowing CPU migration between computing the per-CPU pointer
> and disabling preemption.  They also leave local interrupts enabled
> while using the per-CPU shared memory buffer, allowing a hardirq caller
> (such as mbox_send_message() or mpxy_mbox_msi_write()) to clobber the
> shared memory buffer mid-operation.
>
> Use guard(irqsave)() across all per-CPU shared memory helpers and fetch
> this_cpu_ptr(&mpxy_local) inside the IRQ-disabled section.
>
> Fixes: bf3022a4eb11 ("mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver")
> Closes: https://sashiko.dev/#/bug/linux-d2c1eefe-4777-4ad6-94c5-504e347f3add
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>

This patch is not needed as its being
already taken care by earlier patch sent
but not yet merged -
https://lists.infradead.org/pipermail/linux-riscv/2026-November/104034.html

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-12-03 14:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03  8:28 [PATCH 00/10] mailbox: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03  8:28 ` [PATCH 01/10] mailbox: qcom-ipcc: Skip of_node_put() on phandle parse failure Lee Jones
2026-12-03 10:38   ` Konrad Dybcio
2026-12-03  8:28 ` [PATCH 02/10] mailbox: ti-msgmgr: Use unsigned IDs in ti_msgmgr_of_xlate() Lee Jones
2026-12-03  8:28 ` [PATCH 03/10] mailbox: riscv-sbi-mpxy: Protect per-CPU shmem access with irqsave Lee Jones
2026-12-03 14:32   ` Rahul Pathak
2026-12-03  8:28 ` [PATCH 04/10] mailbox: riscv-sbi-mpxy: Validate shmem bounds in message send helpers Lee Jones
2026-12-03  8:28 ` [PATCH 05/10] mailbox: bcm-pdc: Unregister mailbox controller before destroying DMA pools Lee Jones
2026-12-03  8:28 ` [PATCH 06/10] mailbox: qcom-ipcc: Remove IRQ domain via devm to avoid ISR use-after-free Lee Jones
2026-12-03 10:39   ` Konrad Dybcio
2026-12-03  8:28 ` [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
2026-12-03 13:43   ` Chen-Yu Tsai
2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
2026-12-03 13:49   ` Chen-Yu Tsai
2026-12-03  8:28 ` [PATCH 09/10] mailbox: arm_mhu_db: Initialise channel registers before controller registration Lee Jones
2026-12-03  9:40   ` Sudeep Holla
2026-12-03  8:28 ` [PATCH 10/10] mailbox: ti-msgmgr: Return -EIO on queue error in ti_msgmgr_send_data() Lee Jones

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®