From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Ohad Ben-Cohen <ohad@wizery.com>,
Brian Swetland <swetland@google.com>,
Mark Grosen <mgrosen@ti.com>, Guzman Lugo <fernando.lugo@ti.com>,
Suman Anna <s-anna@ti.com>, Robert Tivy <rtivy@ti.com>,
De Leon <x0095078@ti.com>, Loic Pallardy <loic.pallardy@st.com>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 01/10] remoteproc: core: Fix integer overflow in rproc_check_carveout_da()
Date: Mon, 23 Nov 2026 17:20:45 +0000 [thread overview]
Message-ID: <20261123172140.3547896-2-lee@kernel.org> (raw)
In-Reply-To: <20261123172140.3547896-1-lee@kernel.org>
rproc_check_carveout_da() subtracts two unsigned 32-bit device addresses
and stores the difference in a signed int variable before checking the
carveout bounds. When da exceeds mem->da by 0x80000000 or more, delta
wraps negative; conversely, when da is less than mem->da by more than
0x80000000, delta wraps to a positive integer and bypasses the lower
bound check. Furthermore, delta + len is evaluated in 32-bit unsigned
arithmetic before promotion to size_t, allowing large da and len values
to wrap around 32 bits and bypass the upper bound check as well.
Since len > mem->len is already rejected upfront, compare da < mem->da
directly and check da - mem->da > mem->len - len using subtraction to
eliminate signedness bugs and integer wraparound.
Fixes: c874bf59add0 ("remoteproc: add helper function to check carveout device address")
Closes: https://sashiko.dev/#/bug/linux-8c4ef7d2-a95d-4267-b41e-9023431eba23
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/remoteproc/remoteproc_core.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 23f8539a99bd..2b2ebf39a40a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -287,7 +287,6 @@ static int rproc_check_carveout_da(struct rproc *rproc,
struct rproc_mem_entry *mem, u32 da, u32 len)
{
struct device *dev = &rproc->dev;
- int delta;
/* Check requested resource length */
if (len > mem->len) {
@@ -299,16 +298,14 @@ static int rproc_check_carveout_da(struct rproc *rproc,
/* Address doesn't match registered carveout configuration */
return -EINVAL;
} else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) {
- delta = da - mem->da;
-
/* Check requested resource belongs to registered carveout */
- if (delta < 0) {
+ if (da < mem->da) {
dev_err(dev,
"Registered carveout doesn't fit da request\n");
return -EINVAL;
}
- if (delta + len > mem->len) {
+ if (da - mem->da > mem->len - len) {
dev_err(dev,
"Registered carveout doesn't fit len request\n");
return -EINVAL;
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 17:21 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 ` Lee Jones [this message]
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 ` [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-2-lee@kernel.org \
--to=lee@kernel.org \
--cc=andersson@kernel.org \
--cc=fernando.lugo@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=loic.pallardy@st.com \
--cc=mathieu.poirier@linaro.org \
--cc=mgrosen@ti.com \
--cc=ohad@wizery.com \
--cc=rtivy@ti.com \
--cc=s-anna@ti.com \
--cc=stable@vger.kernel.org \
--cc=swetland@google.com \
--cc=x0095078@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.