Linux-ARM-Kernel Archive on lore.kernel.org
 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 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
  2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
  0 siblings, 2 replies; 3+ 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] 3+ 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
@ 2026-12-03  8:28 ` Lee Jones
  2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones
  1 sibling, 0 replies; 3+ 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 related	[flat|nested] 3+ 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
  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
  1 sibling, 0 replies; 3+ 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 related	[flat|nested] 3+ messages in thread

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

Thread overview: 3+ 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 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Lee Jones
2026-12-03  8:28 ` [PATCH 08/10] mailbox: sun6i-msgbox: Synchronise IRQ during channel shutdown Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox