lkml.org 
[lkml]   [2022]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] remoteproc: imx_rproc: validate resource table
Date
From: Peng Fan <peng.fan@nxp.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@nxp.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
\
 
 \ /
  Last update: 2022-01-11 04:36    [W:0.290 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site