Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers
@ 2026-11-23 17:20 Lee Jones
  2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lee Jones @ 2026-11-23 17:20 UTC (permalink / raw)
  To: lee
  Cc: imx, Peng Fan, Frank Li, Fabio Estevam, Mark Grosen, Hari Nagalla,
	Rob Herring (Arm), Guzman Lugo, Uday Khare, Clement Leger,
	Oleksij Rempel, Sascha Hauer, Ohad Ben-Cohen, HyeongJun An,
	Iuliana Prodan, linux-arm-msm, De Leon, Beleswar Padhi,
	linux-remoteproc, Daniel Baluta, Siddharth Gupta,
	linux-arm-kernel, Hari Kanigeri, Alex Elder, Robert Tivy,
	Loic Pallardy, Mathieu Poirier, Brian Swetland, Bjorn Andersson,
	linux-kernel, Andrew Davis, Tero Kristo, Pengutronix Kernel Team,
	Rishabh Bhatnagar, Shengjiu Wang, Sjur Brændeland

These issues were reported by Sashiko.

None of these changes have been tested on physical hardware.

Cc: "Rob Herring (Arm)" <robh@kernel.org>
Cc: "Sjur Brændeland" <sjur.brandeland@stericsson.com>
Cc: Alex Elder <elder@kernel.org>
Cc: Andrew Davis <afd@ti.com>
Cc: Beleswar Padhi <b-padhi@ti.com>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Brian Swetland <swetland@google.com>
Cc: Clement Leger <cleger@kalray.eu>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: De Leon <x0095078@ti.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>
Cc: Guzman Lugo <fernando.lugo@ti.com>
Cc: Hari Kanigeri <h-kanigeri2@ti.com>
Cc: Hari Nagalla <hnagalla@ti.com>
Cc: HyeongJun An <sammiee5311@gmail.com>
Cc: imx@lists.linux.dev
Cc: Iuliana Prodan <iuliana.prodan@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-remoteproc@vger.kernel.org
Cc: Loic Pallardy <loic.pallardy@st.com>
Cc: Mark Grosen <mgrosen@ti.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
Cc: Robert Tivy <rtivy@ti.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shengjiu Wang <shengjiu.wang@nxp.com>
Cc: Siddharth Gupta <sidgup@codeaurora.org>
Cc: Suman Anna <s-anna@ti.com>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Uday Khare <udaykhare77@gmail.com>

Lee Jones (10):
  remoteproc: core: Fix integer overflow in rproc_check_carveout_da()
  remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va()
  remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va()
  remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments()
  remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure
  remoteproc: imx_rproc: Register SCU cleanup after resource acquisition
  remoteproc: qcom: Clear glink->node on allocation failure
  remoteproc: qcom: Skip unregistering uninitialised SSR subdevice
  remoteproc: imx_dsp_rproc: Fix pointer stride in
    imx_dsp_rproc_memset()
  remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes

 drivers/remoteproc/imx_dsp_rproc.c         | 10 ++++---
 drivers/remoteproc/imx_rproc.c             | 33 ++++++++++++++--------
 drivers/remoteproc/omap_remoteproc.c       | 11 +++++---
 drivers/remoteproc/qcom_common.c           |  5 ++++
 drivers/remoteproc/remoteproc_core.c       |  7 ++---
 drivers/remoteproc/remoteproc_elf_loader.c |  6 ++--
 drivers/remoteproc/ti_k3_common.c          | 27 +++++++++++-------
 7 files changed, 61 insertions(+), 38 deletions(-)

-- 
2.56.1.750.gf70dc682cf-goog



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

* [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure
  2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
@ 2026-11-23 17:20 ` Lee Jones
  2026-11-23 17:20 ` [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition Lee Jones
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-11-23 17:20 UTC (permalink / raw)
  To: lee, Bjorn Andersson, Mathieu Poirier, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Peng Fan, Oleksij Rempel,
	linux-remoteproc, imx, linux-arm-kernel, linux-kernel
  Cc: stable

imx_rproc_xtr_mbox_init() stores the result of
mbox_request_channel_byname() directly into priv->tx_ch and priv->rx_ch.
Because mailbox channels are freed on stop() and detach() and
re-requested on start(), attach(), and system shutdown, a failure while
requesting "tx" leaves an ERR_PTR in priv->tx_ch, which is later
dereferenced by imx_rproc_kick() and imx_rproc_free_mbox().  If "rx"
fails after "tx" succeeds, priv->tx_ch is freed without being cleared
while priv->rx_ch retains an ERR_PTR, causing subsequent calls to see
both pointers as non-NULL and skip initialisation, leading to a
use-after-free on priv->tx_ch and an ERR_PTR dereference on priv->rx_ch.

Request both channels into local variables and assign priv->tx_ch and
priv->rx_ch only after both requests succeed.

Fixes: 99b142cf7191 ("remoteproc: imx_rproc: Request mbox channel later")
Closes: https://sashiko.dev/#/bug/linux-ac0f248a-bdfd-41da-95f8-44b8f1f7091d
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 581bb07f5893..a77a3342e1ed 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -875,6 +875,7 @@ static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
 static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)
 {
 	struct imx_rproc *priv = rproc->priv;
+	struct mbox_chan *tx_ch, *rx_ch;
 	struct device *dev = priv->dev;
 	struct mbox_client *cl;
 
@@ -900,18 +901,21 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)
 	cl->knows_txdone = false;
 	cl->rx_callback = imx_rproc_rx_callback;
 
-	priv->tx_ch = mbox_request_channel_byname(cl, "tx");
-	if (IS_ERR(priv->tx_ch))
-		return dev_err_probe(cl->dev, PTR_ERR(priv->tx_ch),
+	tx_ch = mbox_request_channel_byname(cl, "tx");
+	if (IS_ERR(tx_ch))
+		return dev_err_probe(cl->dev, PTR_ERR(tx_ch),
 				     "failed to request tx mailbox channel\n");
 
-	priv->rx_ch = mbox_request_channel_byname(cl, "rx");
-	if (IS_ERR(priv->rx_ch)) {
-		mbox_free_channel(priv->tx_ch);
-		return dev_err_probe(cl->dev, PTR_ERR(priv->rx_ch),
+	rx_ch = mbox_request_channel_byname(cl, "rx");
+	if (IS_ERR(rx_ch)) {
+		mbox_free_channel(tx_ch);
+		return dev_err_probe(cl->dev, PTR_ERR(rx_ch),
 				     "failed to request rx mailbox channel\n");
 	}
 
+	priv->tx_ch = tx_ch;
+	priv->rx_ch = rx_ch;
+
 	return 0;
 }
 
-- 
2.56.1.750.gf70dc682cf-goog



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

* [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition
  2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
  2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
@ 2026-11-23 17:20 ` Lee Jones
  2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
  2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones
  3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-11-23 17:20 UTC (permalink / raw)
  To: lee, Bjorn Andersson, Mathieu Poirier, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Peng Fan, Oleksij Rempel,
	Daniel Baluta, linux-remoteproc, imx, linux-arm-kernel,
	linux-kernel
  Cc: stable

imx_rproc_scu_api_detect_mode() registers the imx_rproc_put_scu()
devres cleanup action before attaching power domains or registering the
SCU partition reboot notifier and enabling its interrupt group.  If
imx_sc_rm_get_resource_owner() or imx_scu_irq_register_notifier() fails,
imx_rproc_put_scu() runs during failure unwind and unregisters an
unregistered notifier block while disabling an unconfigured interrupt
bit.  Worse, if imx_scu_irq_group_enable() fails, the error path
explicitly unregisters priv->rproc_nb and devres subsequently invokes
imx_rproc_put_scu() to unregister the same notifier block a second time.

Defer devm_add_action_or_reset() until power-domain attachment or SCU
notifier and interrupt setup have completed.

Fixes: 9b2451658afa ("remoteproc: imx_rproc: Use devm_add_action_or_reset() for scu cleanup")
Closes: https://sashiko.dev/#/bug/linux-1230a154-7627-4ce2-96f3-d0033709ba4e
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/imx_rproc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index a77a3342e1ed..9ff2cd50acb6 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -1083,10 +1083,6 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 	else
 		priv->core_index = 0;
 
-	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
-
 	/*
 	 * If Mcore resource is not owned by Acore partition, It is kicked by ROM,
 	 * and Linux could only do IPC with Mcore and nothing else.
@@ -1095,7 +1091,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		if (of_property_read_u32(dev->of_node, "fsl,entry-address", &priv->entry))
 			return -EINVAL;
 
-		return imx_rproc_attach_pd(priv);
+		ret = imx_rproc_attach_pd(priv);
+		if (ret)
+			return ret;
+
+		goto add_scu_action;
 	}
 
 	priv->rproc->state = RPROC_DETACHED;
@@ -1126,6 +1126,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		return ret;
 	}
 
+add_scu_action:
+	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
+
 	return 0;
 }
 
-- 
2.56.1.750.gf70dc682cf-goog



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

* [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset()
  2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
  2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
  2026-11-23 17:20 ` [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition Lee Jones
@ 2026-11-23 17:20 ` Lee Jones
  2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones
  3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-11-23 17:20 UTC (permalink / raw)
  To: lee, Bjorn Andersson, Mathieu Poirier, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
	Iuliana Prodan, linux-remoteproc, imx, linux-arm-kernel,
	linux-kernel
  Cc: stable

Commit 3c497f624d40 ("remoteproc: imx_dsp_rproc: Fix kernel test robot
sparse warning") changed tmp_dst from u32 * to void __iomem *.  In GNU
C, incrementing a void pointer advances it by 1 byte rather than 4
bytes.  Consequently, the word-fill loop in imx_dsp_rproc_memset()
steps by 1 byte per 32-bit writel(), triggering unaligned 32-bit MMIO
accesses on Device-mapped DSP IRAM, mispositioning tmp_dst for the
trailing-byte read-modify-write, and leaving roughly three quarters of
the target region uninitialised.

Advance tmp_dst by 4 bytes per 32-bit word write.

Fixes: 3c497f624d40 ("remoteproc: imx_dsp_rproc: Fix kernel test robot sparse warning")
Closes: https://sashiko.dev/#/bug/linux-720f943f-eefd-4df7-806e-0b50cad1abbe
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/imx_dsp_rproc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 96d619daf3f5..2771043ee433 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -843,8 +843,10 @@ static int imx_dsp_rproc_memset(void *addr, u8 value, size_t size)
 	q = size / 4;
 	r = size % 4;
 
-	while (q--)
-		writel(tmp_val, tmp_dst++);
+	while (q--) {
+		writel(tmp_val, tmp_dst);
+		tmp_dst += 4;
+	}
 
 	if (r) {
 		affected_mask = GENMASK(8 * r, 0);
-- 
2.56.1.750.gf70dc682cf-goog



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

* [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes
  2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
                   ` (2 preceding siblings ...)
  2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
@ 2026-11-23 17:20 ` Lee Jones
  3 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2026-11-23 17:20 UTC (permalink / raw)
  To: lee, Bjorn Andersson, Mathieu Poirier, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
	Iuliana Prodan, linux-remoteproc, imx, linux-arm-kernel,
	linux-kernel
  Cc: stable

When size is not a multiple of 4, both imx_dsp_rproc_memcpy() and
imx_dsp_rproc_memset() compute affected_mask as GENMASK(8 * r, 0) for
the remaining r bytes (1 <= r <= 3).  Because GENMASK(h, l) is inclusive
of bit h, GENMASK(8 * r, 0) sets 8 * r + 1 bits and clears or overwrites
the least-significant bit of the first byte past the end of the target
region during the 32-bit read-modify-write.

Use GENMASK(8 * r - 1, 0) to mask exclusively the r trailing bytes.

Fixes: 408ec1ff0caa ("remoteproc: imx_dsp_rproc: Add custom memory copy implementation for i.MX DSP Cores")
Closes: https://sashiko.dev/#/bug/linux-2e407b68-a7e9-42ff-a613-e61b47a4461b
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/imx_dsp_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 2771043ee433..0e0325d5df9f 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -799,7 +799,7 @@ static int imx_dsp_rproc_memcpy(void *dst, const void *src, size_t size)
 		writel(source[i], dest + i * 4);
 
 	if (r) {
-		affected_mask = GENMASK(8 * r, 0);
+		affected_mask = GENMASK(8 * r - 1, 0);
 
 		/*
 		 * first read the 32bit data of dest, then change affected
@@ -849,7 +849,7 @@ static int imx_dsp_rproc_memset(void *addr, u8 value, size_t size)
 	}
 
 	if (r) {
-		affected_mask = GENMASK(8 * r, 0);
+		affected_mask = GENMASK(8 * r - 1, 0);
 
 		/*
 		 * first read the 32bit data of addr, then change affected
-- 
2.56.1.750.gf70dc682cf-goog



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

end of thread, other threads:[~2026-11-23 17:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
2026-11-23 17:20 ` [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition Lee Jones
2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones

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