[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220111033333.403448-2-peng.fan@oss.nxp.com>
Date: Tue, 11 Jan 2022 11:33:23 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: bjorn.andersson@...aro.org, mathieu.poirier@...aro.org,
shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
festevam@...il.com, linux-imx@....com,
linux-remoteproc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Peng Fan <peng.fan@....com>
Subject: [PATCH] remoteproc: imx_rproc: validate resource table
From: Peng Fan <peng.fan@....com>
Currently NXP use one device tree to support all NXP released Cortex-M
demos. There is one simple demo that not need to communicate with
Linux, thus it will not update the resource table. So there maybe
garbage data in it. In such case, Linux should directly ignore it.
It is hard to decide what data is garbage data, NXP released SDK use
ver(1), reserved(0) in a valid resource table. But in case others
use different value, so here use 0xff as a max value for ver and num.
Signed-off-by: Peng Fan <peng.fan@....com>
---
drivers/remoteproc/imx_rproc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 0bd24c937a73..75fde16f80a4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -490,11 +490,19 @@ static int imx_rproc_attach(struct rproc *rproc)
static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
{
struct imx_rproc *priv = rproc->priv;
+ struct resource_table *table;
/* The resource table has already been mapped in imx_rproc_addr_init */
if (!priv->rsc_table)
return NULL;
+ table = priv->rsc_table;
+ /* Gabage data check */
+ if (table->ver >= 0xff || table->num >= 0xff || table->reserved[0] || table->reserved[1]) {
+ dev_err(priv->dev, "Ignore invalid rsc table\n");
+ return NULL;
+ }
+
*table_sz = SZ_1K;
return (struct resource_table *)priv->rsc_table;
}
--
2.25.1
Powered by blists - more mailing lists