From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
"Rob Herring (Arm)" <robh@kernel.org>, Suman Anna <s-anna@ti.com>,
Hari Nagalla <hnagalla@ti.com>, Beleswar Padhi <b-padhi@ti.com>,
Andrew Davis <afd@ti.com>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 02/10] remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va()
Date: Mon, 23 Nov 2026 17:20:46 +0000 [thread overview]
Message-ID: <20261123172140.3547896-3-lee@kernel.org> (raw)
In-Reply-To: <20261123172140.3547896-1-lee@kernel.org>
k3_rproc_da_to_va() validates memory regions using (da + len) <=
(base + size) and stores da - base in a 32-bit unsigned offset variable.
Because da is u64 and len is size_t, a malformed firmware segment or
resource entry with a large da value causes da + len to wrap around 64
bits and pass the upper bound check. Subsequent assignment to the u32
offset variable truncates the 64-bit difference, returning an
out-of-bounds kernel virtual address to callers such as the ELF segment
loader.
Widen offset to u64 and rewrite the range checks across all three memory
loops using overflow-safe subtraction.
Fixes: 9179f8bfa98d ("remoteproc: k3: Refactor .da_to_va rproc ops into common driver")
Closes: https://sashiko.dev/#/bug/linux-36b3e1ce-919c-4ea8-b7de-b8a5a191c8b4
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/remoteproc/ti_k3_common.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c
index f79ccb57a372..1d06f46b75c6 100644
--- a/drivers/remoteproc/ti_k3_common.c
+++ b/drivers/remoteproc/ti_k3_common.c
@@ -356,7 +356,8 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
struct k3_rproc *kproc = rproc->priv;
void __iomem *va = NULL;
phys_addr_t bus_addr;
- u32 dev_addr, offset;
+ u32 dev_addr;
+ u64 offset;
size_t size;
int i;
@@ -369,17 +370,21 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
size = kproc->mem[i].size;
/* handle rproc-view addresses */
- if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+ if (da >= dev_addr) {
offset = da - dev_addr;
- va = kproc->mem[i].cpu_addr + offset;
- return (__force void *)va;
+ if (offset <= size && len <= size - offset) {
+ va = kproc->mem[i].cpu_addr + offset;
+ return (__force void *)va;
+ }
}
/* handle SoC-view addresses */
- if (da >= bus_addr && (da + len) <= (bus_addr + size)) {
+ if (da >= bus_addr) {
offset = da - bus_addr;
- va = kproc->mem[i].cpu_addr + offset;
- return (__force void *)va;
+ if (offset <= size && len <= size - offset) {
+ va = kproc->mem[i].cpu_addr + offset;
+ return (__force void *)va;
+ }
}
}
@@ -388,10 +393,12 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
dev_addr = kproc->rmem[i].dev_addr;
size = kproc->rmem[i].size;
- if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+ if (da >= dev_addr) {
offset = da - dev_addr;
- va = kproc->rmem[i].cpu_addr + offset;
- return (__force void *)va;
+ if (offset <= size && len <= size - offset) {
+ va = kproc->rmem[i].cpu_addr + offset;
+ return (__force void *)va;
+ }
}
}
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 17:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
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 01/10] remoteproc: core: Fix integer overflow in rproc_check_carveout_da() Lee Jones
2026-11-23 17:20 ` Lee Jones [this message]
2026-11-23 17:20 ` [PATCH 03/10] remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` [PATCH 04/10] remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments() Lee Jones
2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
2026-11-24 3:23 ` Peng Fan (OSS)
2026-11-25 6:23 ` Richard Leitner
2026-11-25 6:27 ` Richard Leitner
2026-11-26 9:16 ` Lee Jones
2026-11-23 17:20 ` [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition Lee Jones
2026-11-24 3:25 ` Peng Fan (OSS)
2026-11-23 17:20 ` [PATCH 07/10] remoteproc: qcom: Clear glink->node on allocation failure Lee Jones
2026-11-23 17:20 ` [PATCH 08/10] remoteproc: qcom: Skip unregistering uninitialised SSR subdevice Lee Jones
2026-11-23 22:25 ` Alex Elder
2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
2026-11-24 3:25 ` Peng Fan (OSS)
2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones
2026-11-24 3:26 ` Peng Fan (OSS)
2026-11-27 16:40 ` [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Mathieu Poirier
2026-11-27 16:40 ` Mathieu Poirier
2026-11-30 14:55 ` Lee Jones
2026-11-30 14:55 ` Lee Jones
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=20261123172140.3547896-3-lee@kernel.org \
--to=lee@kernel.org \
--cc=afd@ti.com \
--cc=andersson@kernel.org \
--cc=b-padhi@ti.com \
--cc=hnagalla@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=robh@kernel.org \
--cc=s-anna@ti.com \
--cc=stable@vger.kernel.org \
/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.