From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795015642; b=JAs+b9FrwDCQhas22PCeHoDCQbq8m1J4Ppc4fwT+7xYDwBkc+kyrC0yCZz+K6mXWwTiM L2GG0NAEGs3jSEw8nxwEkGqobr4Hy5Hd/yz2xrOqbjtgcsT5ZqN/u7JQEAivEXjeKaQwV yLp7C3ms3iMYHaVoRSFs4Js6B78vVdsieaujiUH+BsWdgjU61ipohzR+xw0UdxWqvcZV9 vQqXdxec9sfTjjsLOxnUGyGOQJ607Vcx5uAAyKamouKZekAVdmtUiANpfszOzg2QbfA8d JOapH5iookxaD8CyNjbPJLZZKnUugrQEF1PO8rkBwvraLwVNLgr06vnE8m/M7468rqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795015642; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Xt9yS64IyWkL/Nwe1IPdvGdrKG7/67+AVv+yEUtHEa8=; b=CJcxv2AhFGm1iqEdjJxRpMOr58dbmgIjvZKCdhJWaI6buaMkP+W/B8MN1YoEtJ4u9MfE W1QECGRsjGL21Y1TQ4m5zcWFBD/++AQpLWZZigv+iZ1PdzScl4XdRb776UqnuCV2HAUAk j2qN5tJNDrSqD+wPXrFOob7bDvB99J5sI0NbkcWFU++d2iUO0sV7yjXh+hpn+x0H4DitU EwivmTsnmiIvkwdD55UTSR40oXBzNkvrfNkcPCds2uG5/bvUdutub5X/MiA5tGlhh/+U6 PQOmA9LjP4DqBMFFMWrhbEIdTAnY2UwZqiBPQvRJPNIjTuBEn4xyt8q8srX7BJi3A6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nnQDcCHf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7553B60A2602; Wed, 18 Nov 2026 15:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nnQDcCHf Received: by smtp.kernel.org (Postfix) with ESMTPSA id C95131F000C7; Wed, 18 Nov 2026 15:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795015642; bh=Xt9yS64IyWkL/Nwe1IPdvGdrKG7/67+AVv+yEUtHEa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nnQDcCHffuGPHOwitmmJMGqWuPuF2b/NQtfwW7xtzFdogtq1defahuYneY/rqMnOt 9cFoqP0J1s5p+7kDqHwoCAbhtjoa0qzJgizDzwK73y+Ns9KwwR6dKZGPbEiJZQptbL d+2AvcC+pg1wuk2OEGztqeYltoZyknQ0ZPANOSVs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marcel Hofmann , Mathieu Poirier , Sasha Levin , Peng Fan Subject: [PATCH 7.3 0244/2651] remoteproc: imx_rproc: Allow mappings ending at region boundary Date: Wed, 18 Nov 2026 15:24:44 +0100 Message-ID: <20261118150256.641854456@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marcel Hofmann [ Upstream commit 749eed0c7178c8d53ce4c9acdda4a545721c494b ] The address range checks in imx_rproc_da_to_sys() and imx_rproc_da_to_va() use a strict comparison for the exclusive end address of the requested range. As a result, a valid request that ends exactly at the end of an address translation or mapped memory region is rejected. For a region [start, start + size), a request [addr, addr + len) is contained when: addr >= start && addr + len <= start + size This occurs when a loadable ELF segment fills an entire mapped memory region. This can be produced by a linker script that extends the resource table section to the end of its designated region: .resource_table : { . = ALIGN(8); KEEP(*(.resource_table)) /* Resource table */ . = ALIGN(8); . = ORIGIN(m_rsc_tbl) + LENGTH(m_rsc_tbl); } > m_rsc_tbl =0x00 This produces a ELF program header like: LOAD 0x010000 0xa4220000 0xa4220000 0x01000 0x01000 R 0x1000 In this case, the segment size matches the mapped region size exactly, causing the address translation to fail with: bad phdr da 0xa4220000 mem 0x1000 Rework the upper-bound checks to allow ranges ending exactly at the region boundary while guarding against integer overflow. Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver") Signed-off-by: Marcel Hofmann Tested-by: Peng Fan #i.MX95-19x19-EVK Link: https://lore.kernel.org/r/20260827123136.438798-1-marcel@hofmania.de Signed-off-by: Mathieu Poirier Signed-off-by: Sasha Levin --- drivers/remoteproc/imx_rproc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 745ce52cd8226..ea852ca143bb5 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -540,6 +540,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, /* parse address translation table */ for (i = 0; i < dcfg->att_size; i++) { const struct imx_rproc_att *att = &dcfg->att[i]; + u64 offset; /* * Ignore entries not belong to current core: @@ -552,9 +553,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, continue; } - if (da >= att->da && da + len < att->da + att->size) { - unsigned int offset = da - att->da; + if (da < att->da) + continue; + offset = da - att->da; + if (offset <= att->size && len <= att->size - offset) { *sys = att->sa + offset; if (is_iomem) *is_iomem = att->flags & ATT_IOMEM; @@ -585,9 +588,14 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *i return NULL; for (i = 0; i < IMX_RPROC_MEM_MAX; i++) { - if (sys >= priv->mem[i].sys_addr && sys + len < - priv->mem[i].sys_addr + priv->mem[i].size) { - unsigned int offset = sys - priv->mem[i].sys_addr; + u64 offset; + + if (sys < priv->mem[i].sys_addr) + continue; + + offset = sys - priv->mem[i].sys_addr; + if (offset <= priv->mem[i].size && + len <= priv->mem[i].size - offset) { /* __force to make sparse happy with type conversion */ va = (__force void *)(priv->mem[i].cpu_addr + offset); break; -- 2.53.0