* [PATCH 0/2] remoteproc: qcom_q6v5: Fix 64-bit address truncation in ADSP and PAS drivers
@ 2026-09-21 16:36 Anup Vishwakarma
2026-09-21 16:36 ` [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation Anup Vishwakarma
2026-09-21 16:36 ` [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation Anup Vishwakarma
0 siblings, 2 replies; 7+ messages in thread
From: Anup Vishwakarma @ 2026-09-21 16:36 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel, Anup Vishwakarma
These two patches resolve signed 32-bit integer truncation bugs in
the segment dump and address translation callbacks of the ADSP and
PAS remoteproc drivers, using unsigned size_t offsets and explicit
comparison-based bounds checking.
Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
---
Anup Vishwakarma (2):
remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation
remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation
drivers/remoteproc/qcom_q6v5_adsp.c | 7 +++++--
drivers/remoteproc/qcom_q6v5_pas.c | 22 +++++++++++++++++-----
2 files changed, 22 insertions(+), 7 deletions(-)
---
base-commit: 5c4d4169604b335c38bbc79bc1fc03042981fc6f
change-id: 20260921-b4-q6v5_address_truncation_fixes_upstream-dc59f0579896
Best regards,
--
Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation
2026-09-21 16:36 [PATCH 0/2] remoteproc: qcom_q6v5: Fix 64-bit address truncation in ADSP and PAS drivers Anup Vishwakarma
@ 2026-09-21 16:36 ` Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:13 ` Konrad Dybcio
2026-09-21 16:36 ` [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation Anup Vishwakarma
1 sibling, 2 replies; 7+ messages in thread
From: Anup Vishwakarma @ 2026-09-21 16:36 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel, Anup Vishwakarma
In qcom_pas_segment_dump() and qcom_pas_da_to_va(), the offset
calculation results are stored in signed 32-bit integers (total_offset
and offset). On 64-bit architectures, this can truncate the 64-bit
address arithmetic result if the subtraction or addition exceeds 2GB,
causing erroneous bounds check failures or invalid pointer translations.
Fix this by using unsigned size_t offsets and explicit comparison-based
bounds checking. Check that the address is above the base before
subtracting, and use the form (len > mem_size - offset) instead of
(offset + len > mem_size) to avoid unsigned overflow.
Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
---
drivers/remoteproc/qcom_q6v5_pas.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index a005546c265d..c95a030949d7 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -130,10 +130,19 @@ static void qcom_pas_segment_dump(struct rproc *rproc,
void *dest, size_t offset, size_t size)
{
struct qcom_pas *pas = rproc->priv;
- int total_offset;
+ u64 addr = segment->da + segment->offset + offset;
+ size_t total_offset;
- total_offset = segment->da + segment->offset + offset - pas->mem_phys;
- if (total_offset < 0 || total_offset + size > pas->mem_size) {
+ if (addr < pas->mem_phys) {
+ dev_err(pas->dev,
+ "invalid copy request for segment %pad with offset %zu and size %zu)\n",
+ &segment->da, offset, size);
+ memset(dest, 0xff, size);
+ return;
+ }
+
+ total_offset = addr - pas->mem_phys;
+ if (total_offset > pas->mem_size || size > pas->mem_size - total_offset) {
dev_err(pas->dev,
"invalid copy request for segment %pad with offset %zu and size %zu)\n",
&segment->da, offset, size);
@@ -445,10 +454,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;
+ size_t 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)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation
2026-09-21 16:36 [PATCH 0/2] remoteproc: qcom_q6v5: Fix 64-bit address truncation in ADSP and PAS drivers Anup Vishwakarma
2026-09-21 16:36 ` [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation Anup Vishwakarma
@ 2026-09-21 16:36 ` Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:11 ` Konrad Dybcio
1 sibling, 2 replies; 7+ messages in thread
From: Anup Vishwakarma @ 2026-09-21 16:36 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel, Anup Vishwakarma
In adsp_da_to_va(), the offset calculation results are stored in a
signed 32-bit integer (offset). On 64-bit architectures, this can
truncate the 64-bit address arithmetic result if the subtraction exceeds
2GB, causing erroneous bounds check failures or invalid pointer
translations.
Fix this by using an unsigned size_t offset and explicit comparison-based
bounds checking. Check that the address is above the base before
subtracting, and use the form (len > mem_size - offset) instead of
(offset + len > mem_size) to avoid unsigned overflow.
Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
---
drivers/remoteproc/qcom_q6v5_adsp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c
index 46d9169a37f6..b014e7498f63 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;
+ size_t 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;
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation
2026-09-21 16:36 ` [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation Anup Vishwakarma
@ 2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:13 ` Konrad Dybcio
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-10-21 10:10 UTC (permalink / raw)
To: Anup Vishwakarma, Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel
On 9/21/26 6:36 PM, Anup Vishwakarma wrote:
> In qcom_pas_segment_dump() and qcom_pas_da_to_va(), the offset
> calculation results are stored in signed 32-bit integers (total_offset
> and offset). On 64-bit architectures, this can truncate the 64-bit
> address arithmetic result if the subtraction or addition exceeds 2GB,
> causing erroneous bounds check failures or invalid pointer translations.
>
> Fix this by using unsigned size_t offsets and explicit comparison-based
> bounds checking. Check that the address is above the base before
> subtracting, and use the form (len > mem_size - offset) instead of
> (offset + len > mem_size) to avoid unsigned overflow.
>
> Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation
2026-09-21 16:36 ` [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation Anup Vishwakarma
@ 2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:11 ` Konrad Dybcio
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-10-21 10:10 UTC (permalink / raw)
To: Anup Vishwakarma, Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel
On 9/21/26 6:36 PM, Anup Vishwakarma wrote:
> In adsp_da_to_va(), the offset calculation results are stored in a
> signed 32-bit integer (offset). On 64-bit architectures, this can
> truncate the 64-bit address arithmetic result if the subtraction exceeds
> 2GB, causing erroneous bounds check failures or invalid pointer
> translations.
>
> Fix this by using an unsigned size_t offset and explicit comparison-based
> bounds checking. Check that the address is above the base before
> subtracting, and use the form (len > mem_size - offset) instead of
> (offset + len > mem_size) to avoid unsigned overflow.
>
> Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation
2026-09-21 16:36 ` [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
@ 2026-10-21 10:11 ` Konrad Dybcio
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-10-21 10:11 UTC (permalink / raw)
To: Anup Vishwakarma, Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel
On 9/21/26 6:36 PM, Anup Vishwakarma wrote:
> In adsp_da_to_va(), the offset calculation results are stored in a
> signed 32-bit integer (offset). On 64-bit architectures, this can
> truncate the 64-bit address arithmetic result if the subtraction exceeds
> 2GB, causing erroneous bounds check failures or invalid pointer
> translations.
>
> Fix this by using an unsigned size_t offset and explicit comparison-based
> bounds checking. Check that the address is above the base before
> subtracting, and use the form (len > mem_size - offset) instead of
> (offset + len > mem_size) to avoid unsigned overflow.
>
> Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
> ---
Fixes: dc160e449122 ("remoteproc: qcom: Introduce Non-PAS ADSP PIL driver")
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation
2026-09-21 16:36 ` [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
@ 2026-10-21 10:13 ` Konrad Dybcio
1 sibling, 0 replies; 7+ messages in thread
From: Konrad Dybcio @ 2026-10-21 10:13 UTC (permalink / raw)
To: Anup Vishwakarma, Bjorn Andersson, Mathieu Poirier
Cc: linux-arm-msm, linux-remoteproc, linux-kernel
On 9/21/26 6:36 PM, Anup Vishwakarma wrote:
> In qcom_pas_segment_dump() and qcom_pas_da_to_va(), the offset
> calculation results are stored in signed 32-bit integers (total_offset
> and offset). On 64-bit architectures, this can truncate the 64-bit
> address arithmetic result if the subtraction or addition exceeds 2GB,
> causing erroneous bounds check failures or invalid pointer translations.
>
> Fix this by using unsigned size_t offsets and explicit comparison-based
> bounds checking. Check that the address is above the base before
> subtracting, and use the form (len > mem_size - offset) instead of
> (offset + len > mem_size) to avoid unsigned overflow.
>
> Signed-off-by: Anup Vishwakarma <anup.vishwakarma@oss.qualcomm.com>
> ---
Fixes: a376c10d45a8 ("remoteproc: qcom: pas: Adjust the phys addr wrt the mem region")
Konrad
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-21 10:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 16:36 [PATCH 0/2] remoteproc: qcom_q6v5: Fix 64-bit address truncation in ADSP and PAS drivers Anup Vishwakarma
2026-09-21 16:36 ` [PATCH 1/2] remoteproc: qcom_q6v5_pas: Fix 64-bit address truncation in dump and translation Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:13 ` Konrad Dybcio
2026-09-21 16:36 ` [PATCH 2/2] remoteproc: qcom_q6v5_adsp: Fix 64-bit address truncation in translation Anup Vishwakarma
2026-10-21 10:10 ` Konrad Dybcio
2026-10-21 10:11 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®