* [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation
@ 2026-11-27 9:07 Gopikrishna Garmidi
2026-11-27 9:28 ` Atul Akella
0 siblings, 1 reply; 4+ messages in thread
From: Gopikrishna Garmidi @ 2026-11-27 9:07 UTC (permalink / raw)
To: andersson, mathieu.poirier, konrad.dybcio, abelvesa
Cc: niklas.cassel, rohitkr, sibi.sankar, robh, quic_srichara,
konradybcio, rajendra.nayak, linux-arm-msm, linux-remoteproc,
Gopikrishna Garmidi
The da_to_va() callbacks compute the offset into the carveout as an int
from a u64 device address. An address such as mem_reloc + 0x100000010
truncates to 0x10, passes the bounds check and gets mapped to the wrong
place. The check "offset + len > mem_size" can also overflow.
The device address comes from ELF program headers and the resource table
of the firmware image, which are parsed before the image is
authenticated.
Use a u64 offset, reject addresses below the carveout base and compare
without risking overflow. Apply the same change to the pas, adsp, wcss
and wcnss drivers, which all share this pattern.
Fixes: 9e004f97161d ("remoteproc: qcom: Rename Hexagon v5 PAS driver")
Fixes: dc160e449122 ("remoteproc: qcom: Introduce Non-PAS ADSP PIL driver")
Fixes: 3a3d4163e0bf ("remoteproc: qcom: Introduce Hexagon V5 based WCSS driver")
Fixes: aed361adca9f ("remoteproc: qcom: Introduce WCNSS peripheral image loader")
Signed-off-by: Gopikrishna Garmidi <gopikrishna.garmidi@oss.qualcomm.com>
Assisted-by: LLM
---
drivers/remoteproc/qcom_q6v5_adsp.c | 7 +++++--
drivers/remoteproc/qcom_q6v5_pas.c | 7 +++++--
drivers/remoteproc/qcom_q6v5_wcss.c | 7 +++++--
drivers/remoteproc/qcom_wcnss.c | 7 +++++--
4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c
index 23fabf4ce84d..d9d12f67ee25 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -486,10 +486,13 @@ static int adsp_stop(struct rproc *rproc)
static void *adsp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
{
struct qcom_adsp *adsp = rproc->priv;
- int offset;
+ u64 offset;
+
+ if (da < adsp->mem_reloc)
+ return NULL;
offset = da - adsp->mem_reloc;
- if (offset < 0 || offset + len > adsp->mem_size)
+ if (offset > adsp->mem_size || len > adsp->mem_size - offset)
return NULL;
return (__force void *)adsp->mem_region + offset;
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index ff2483529d73..232bf9b349cf 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -473,10 +473,13 @@ static int qcom_pas_stop(struct rproc *rproc)
static void *qcom_pas_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
{
struct qcom_pas *pas = rproc->priv;
- int offset;
+ u64 offset;
+
+ if (da < pas->mem_reloc)
+ return NULL;
offset = da - pas->mem_reloc;
- if (offset < 0 || offset + len > pas->mem_size)
+ if (offset > pas->mem_size || len > pas->mem_size - offset)
return NULL;
if (is_iomem)
diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c
index b391724cfd08..52d9b5174e8a 100644
--- a/drivers/remoteproc/qcom_q6v5_wcss.c
+++ b/drivers/remoteproc/qcom_q6v5_wcss.c
@@ -740,10 +740,13 @@ static int q6v5_wcss_stop(struct rproc *rproc)
static void *q6v5_wcss_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
{
struct q6v5_wcss *wcss = rproc->priv;
- int offset;
+ u64 offset;
+
+ if (da < wcss->mem_reloc)
+ return NULL;
offset = da - wcss->mem_reloc;
- if (offset < 0 || offset + len > wcss->mem_size)
+ if (offset > wcss->mem_size || len > wcss->mem_size - offset)
return NULL;
return wcss->mem_region + offset;
diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
index 02f38fe29f20..cf8d1aa8f38f 100644
--- a/drivers/remoteproc/qcom_wcnss.c
+++ b/drivers/remoteproc/qcom_wcnss.c
@@ -321,10 +321,13 @@ static int wcnss_stop(struct rproc *rproc)
static void *wcnss_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
{
struct qcom_wcnss *wcnss = rproc->priv;
- int offset;
+ u64 offset;
+
+ if (da < wcnss->mem_reloc)
+ return NULL;
offset = da - wcnss->mem_reloc;
- if (offset < 0 || offset + len > wcnss->mem_size)
+ if (offset > wcnss->mem_size || len > wcnss->mem_size - offset)
return NULL;
return (__force void *)wcnss->mem_region + offset;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation
2026-11-27 9:07 [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation Gopikrishna Garmidi
@ 2026-11-27 9:28 ` Atul Akella
2026-11-27 9:41 ` Gopikrishna Garmidi
0 siblings, 1 reply; 4+ messages in thread
From: Atul Akella @ 2026-11-27 9:28 UTC (permalink / raw)
To: gopikrishna.garmidi, andersson, mathieu.poirier, konrad.dybcio,
abelvesa
Cc: niklas.cassel, rohitkr, sibi.sankar, robh, quic_srichara,
konradybcio, rajendra.nayak, linux-arm-msm, linux-remoteproc
On Fri, Nov 27, 2026 at 01:07:50AM -0800, Gopikrishna Garmidi wrote:
> The da_to_va() callbacks compute the offset into the carveout as an int
> from a u64 device address. An address such as mem_reloc + 0x100000010
> truncates to 0x10, passes the bounds check and gets mapped to the wrong
> place. The check "offset + len > mem_size" can also overflow.
>
> Use a u64 offset, reject addresses below the carveout base and compare
> without risking overflow. Apply the same change to the pas, adsp, wcss
> and wcnss drivers, which all share this pattern.
Hi Gopikrishna,
This overlaps with a series I sent on Nov 7 covering the same four
drivers and the same root cause (int offset truncating the u64
da base subtraction):
https://lore.kernel.org/linux-remoteproc/20261106184312.100-1-atul.akella@gmail.com/
Mine's still awaiting review, so happy to defer or let the maintainers
pick whichever they'd rather carry forward. Wanted to flag the overlap
before there's duplicate review effort on both sides.
Atul
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation
2026-11-27 9:28 ` Atul Akella
@ 2026-11-27 9:41 ` Gopikrishna Garmidi
2026-11-27 10:06 ` Atul Akella
0 siblings, 1 reply; 4+ messages in thread
From: Gopikrishna Garmidi @ 2026-11-27 9:41 UTC (permalink / raw)
To: Atul Akella, andersson, mathieu.poirier, konrad.dybcio, abelvesa
Cc: niklas.cassel, rohitkr, sibi.sankar, robh, quic_srichara,
konradybcio, rajendra.nayak, linux-arm-msm, linux-remoteproc
On 11/27/2026 2:58 PM, Atul Akella wrote:
> On Fri, Nov 27, 2026 at 01:07:50AM -0800, Gopikrishna Garmidi wrote:
>> The da_to_va() callbacks compute the offset into the carveout as an int
>> from a u64 device address. An address such as mem_reloc + 0x100000010
>> truncates to 0x10, passes the bounds check and gets mapped to the wrong
>> place. The check "offset + len > mem_size" can also overflow.
>>
>> Use a u64 offset, reject addresses below the carveout base and compare
>> without risking overflow. Apply the same change to the pas, adsp, wcss
>> and wcnss drivers, which all share this pattern.
>
> Hi Gopikrishna,
>
> This overlaps with a series I sent on Nov 7 covering the same four
> drivers and the same root cause (int offset truncating the u64
> da base subtraction):
>
> https://lore.kernel.org/linux-remoteproc/20261106184312.100-1-atul.akella@gmail.com/
>
> Mine's still awaiting review, so happy to defer or let the maintainers
> pick whichever they'd rather carry forward. Wanted to flag the overlap
> before there's duplicate review effort on both sides.
>
Hi Atul,
Thanks for pointing that out, I missed your series. Yours came first and
covers the same four drivers with the same change, so please go ahead
with it. I'm dropping this patch and will review yours instead.
Thanks,
Gopikrishna
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation
2026-11-27 9:41 ` Gopikrishna Garmidi
@ 2026-11-27 10:06 ` Atul Akella
0 siblings, 0 replies; 4+ messages in thread
From: Atul Akella @ 2026-11-27 10:06 UTC (permalink / raw)
To: Gopikrishna Garmidi, andersson, mathieu.poirier, konrad.dybcio,
abelvesa
Cc: niklas.cassel, rohitkr, sibi.sankar, robh, quic_srichara,
konradybcio, rajendra.nayak, linux-arm-msm, linux-remoteproc
On 27-11-2026 15:11, Gopikrishna Garmidi wrote:
>
>
> On 11/27/2026 2:58 PM, Atul Akella wrote:
>> On Fri, Nov 27, 2026 at 01:07:50AM -0800, Gopikrishna Garmidi wrote:
>>> The da_to_va() callbacks compute the offset into the carveout as an int
>>> from a u64 device address. An address such as mem_reloc + 0x100000010
>>> truncates to 0x10, passes the bounds check and gets mapped to the wrong
>>> place. The check "offset + len > mem_size" can also overflow.
>>>
>>> Use a u64 offset, reject addresses below the carveout base and compare
>>> without risking overflow. Apply the same change to the pas, adsp, wcss
>>> and wcnss drivers, which all share this pattern.
>>
>> Hi Gopikrishna,
>>
>> This overlaps with a series I sent on Nov 7 covering the same four
>> drivers and the same root cause (int offset truncating the u64
>> da base subtraction):
>>
>> https://lore.kernel.org/linux-remoteproc/20261106184312.100-1-
>> atul.akella@gmail.com/
>>
>> Mine's still awaiting review, so happy to defer or let the maintainers
>> pick whichever they'd rather carry forward. Wanted to flag the overlap
>> before there's duplicate review effort on both sides.
>>
>
> Hi Atul,
>
> Thanks for pointing that out, I missed your series. Yours came first and
> covers the same four drivers with the same change, so please go ahead
> with it. I'm dropping this patch and will review yours instead.
>
> Thanks,
> Gopikrishna
Hi Gopikrishna,
Appreciate you checking and deferring; Thanks for taking the time to
review mine too.
Thanks,
Atul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-27 10:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 9:07 [PATCH] remoteproc: qcom: Fix da_to_va() offset truncation Gopikrishna Garmidi
2026-11-27 9:28 ` Atul Akella
2026-11-27 9:41 ` Gopikrishna Garmidi
2026-11-27 10:06 ` Atul Akella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox