All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Andrew Davis <afd@ti.com>, Ohad Ben-Cohen <ohad@wizery.com>,
	Brian Swetland <swetland@google.com>,
	Guzman Lugo <fernando.lugo@ti.com>, Mark Grosen <mgrosen@ti.com>,
	Suman Anna <s-anna@ti.com>, Hari Kanigeri <h-kanigeri2@ti.com>,
	Tero Kristo <t-kristo@ti.com>,
	linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 03/10] remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va()
Date: Mon, 23 Nov 2026 17:20:47 +0000	[thread overview]
Message-ID: <20261123172140.3547896-4-lee@kernel.org> (raw)
In-Reply-To: <20261123172140.3547896-1-lee@kernel.org>

omap_rproc_da_to_va() checks da + len <= dev_addr + size using 64-bit
unsigned addition and stores da - dev_addr in a 32-bit unsigned offset
variable.  A crafted firmware segment or resource entry with a large
da value can wrap da + len around 64 bits, bypassing the upper bound
check, while truncating da - dev_addr to 32 bits yields an
out-of-bounds pointer offset into kernel memory.

Widen offset to u64 and validate both offset <= size and
len <= size - offset without addition overflow.

Fixes: 530a1b57e859 ("remoteproc/omap: Add the rproc ops .da_to_va() implementation")
Closes: https://sashiko.dev/#/bug/linux-e1bfa1ec-93c7-47ac-aba5-bce08be0f756
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/remoteproc/omap_remoteproc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c
index f52a531877ae..573f8d9ae8eb 100644
--- a/drivers/remoteproc/omap_remoteproc.c
+++ b/drivers/remoteproc/omap_remoteproc.c
@@ -735,7 +735,7 @@ static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *
 {
 	struct omap_rproc *oproc = rproc->priv;
 	int i;
-	u32 offset;
+	u64 offset;
 
 	if (len <= 0)
 		return NULL;
@@ -744,9 +744,12 @@ static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *
 		return NULL;
 
 	for (i = 0; i < oproc->num_mems; i++) {
-		if (da >= oproc->mem[i].dev_addr && da + len <=
-		    oproc->mem[i].dev_addr + oproc->mem[i].size) {
-			offset = da - oproc->mem[i].dev_addr;
+		if (da < oproc->mem[i].dev_addr)
+			continue;
+
+		offset = da - oproc->mem[i].dev_addr;
+		if (offset <= oproc->mem[i].size &&
+		    len <= oproc->mem[i].size - offset) {
 			/* __force to make sparse happy with type conversion */
 			return (__force void *)(oproc->mem[i].cpu_addr +
 						offset);
-- 
2.56.1.750.gf70dc682cf-goog


  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 ` [PATCH 02/10] remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` Lee Jones [this message]
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-4-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=afd@ti.com \
    --cc=andersson@kernel.org \
    --cc=fernando.lugo@ti.com \
    --cc=h-kanigeri2@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mgrosen@ti.com \
    --cc=ohad@wizery.com \
    --cc=s-anna@ti.com \
    --cc=stable@vger.kernel.org \
    --cc=swetland@google.com \
    --cc=t-kristo@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.