From: Atul Akella <atul.akella@gmail.com>
To: andersson@kernel.org, mathieu.poirier@linaro.org, s-anna@ti.com,
b-padhi@ti.com
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
Atul Akella <atul.akella@gmail.com>
Subject: [PATCH] remoteproc: k3-r5: Fix integer overflow in SRAM address translation
Date: Thu, 3 Dec 2026 00:25:51 +0530 [thread overview]
Message-ID: <20261202185552.75-1-atul.akella@gmail.com> (raw)
The SRAM address translation path in k3_r5_rproc_da_to_va()
checks the requested range using da + len. This addition can
overflow, allowing an out of bounds range to pass the check.
The offset is also stored in a u32, which can truncate the
difference when da is greater than the 32bit device address.
Use a u64 for the offset and validate the range using
subtraction-based bounds checks to avoid both issues.
Fixes: ea47c6887b6d ("remoteproc: k3-r5: Add loading support for on-chip SRAM regions")
Signed-off-by: Atul Akella <atul.akella@gmail.com>
---
drivers/remoteproc/ti_k3_r5_remoteproc.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index d7d9756afed0..13795c753441 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -567,7 +567,8 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool
struct k3_rproc *kproc = rproc->priv;
struct k3_r5_core *core = kproc->priv;
void __iomem *va = NULL;
- u32 dev_addr, offset;
+ u32 dev_addr;
+ u64 offset;
size_t size;
int i;
@@ -579,10 +580,12 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool
dev_addr = core->sram[i].dev_addr;
size = core->sram[i].size;
- if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+ if (da >= dev_addr) {
offset = da - dev_addr;
- va = core->sram[i].cpu_addr + offset;
- return (__force void *)va;
+ if (offset <= size && len <= size - offset) {
+ va = core->sram[i].cpu_addr + offset;
+ return (__force void *)va;
+ }
}
}
--
2.43.0
reply other threads:[~2026-12-02 18:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202185552.75-1-atul.akella@gmail.com \
--to=atul.akella@gmail.com \
--cc=andersson@kernel.org \
--cc=b-padhi@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=s-anna@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.