mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading
@ 2026-08-20 14:30 Viken Dadhaniya
  2026-08-20 14:30 ` [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison Viken Dadhaniya
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-20 14:30 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Viken Dadhaniya, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

This series fixes four issues in geni_find_protocol_fw() and
geni_load_se_fw(), all introduced by commit d4bf06592ad6 ("soc: qcom:
geni-se: Add support to load QUP SE Firmware via Linux subsystem").

The most critical issue (patch 4/4) causes a level-3 permission fault
and crashes the kernel during QUP firmware load on CentOS; writing through
a non-const cast into a read-only firmware mapping is undefined behavior
regardless of whether the fault is raised.

The remaining three patches fix related issues that were uncovered while
addressing the above:

- The fw_end bounds check was computed from the unrounded fw_size,
  allowing an odd-word-count segment to pass validation but trigger an
  out-of-bounds read during the subsequent memcpy_toio() (patch 3/4).

- fw_size was stored as u16; incrementing 0xffff silently wraps to 0,
  bypassing the MAX_GENI_CFG_RAMn_CNT check and permitting an
  arbitrarily large copy into SE RAM (patch 2/4).

- serial_protocol is __le16 but was decoded with le32_to_cpu(), causing
  the protocol match to always fail on big-endian systems and preventing
  any firmware from loading (patch 1/4).

---
Changes in v2:
- Split into four atomic patches (one fix per commit) for easier review and bisection.
- Link to v1: https://patch.msgid.link/20260819-fix-write-to-read-only-firmware-buffer-v1-1-be86532fe122@oss.qualcomm.com

---
Viken Dadhaniya (4):
      soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison
      soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around
      soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller
      soc: qcom: geni-se: Fix write to read-only firmware buffer

 drivers/soc/qcom/qcom-geni-se.c | 45 ++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
---
base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d
change-id: 20260819-fix-write-to-read-only-firmware-buffer-39ca7834e310

Best regards,
--  
Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison
  2026-08-20 14:30 [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading Viken Dadhaniya
@ 2026-08-20 14:30 ` Viken Dadhaniya
  2026-08-20 14:40   ` Konrad Dybcio
  2026-08-20 14:30 ` [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around Viken Dadhaniya
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-20 14:30 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Viken Dadhaniya, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

serial_protocol is declared as __le16 in struct se_fw_hdr, but was
decoded with le32_to_cpu(). On big-endian systems the extra byte swap
causes the field to always compare unequal to the protocol argument,
so no firmware segment is ever selected.

Use le16_to_cpu() to match the field width.

Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
---
 drivers/soc/qcom/qcom-geni-se.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 873bfbd6b2b7..1d6e6611441d 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1298,7 +1298,7 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 		if (le32_to_cpu(sefw->magic) != SE_MAGIC_NUM || le32_to_cpu(sefw->version) != 1)
 			continue;
 
-		if (le32_to_cpu(sefw->serial_protocol) != protocol)
+		if (le16_to_cpu(sefw->serial_protocol) != protocol)
 			continue;
 
 		if (fw_size % 2 != 0) {

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around
  2026-08-20 14:30 [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading Viken Dadhaniya
  2026-08-20 14:30 ` [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison Viken Dadhaniya
@ 2026-08-20 14:30 ` Viken Dadhaniya
  2026-08-20 14:40   ` Konrad Dybcio
  2026-08-20 14:31 ` [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller Viken Dadhaniya
  2026-08-20 14:31 ` [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer Viken Dadhaniya
  3 siblings, 1 reply; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-20 14:30 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Viken Dadhaniya, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

fw_size is read from the 16-bit fw_size_in_items field and incremented
when the count is odd. If fw_size_in_items == 0xffff the increment
wraps to 0 as a u16, making the bounds check below pass for a firmware
segment whose actual size was not validated. Widen fw_size to u32 so
the increment never wraps.

Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
---
 drivers/soc/qcom/qcom-geni-se.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 1d6e6611441d..54c0a66d6dd6 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1248,7 +1248,7 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 	struct se_fw_hdr *sefw;
 	u32 fw_end, cfg_idx_end, cfg_val_end;
 	u32 prog_ram_depth;
-	u16 fw_size;
+	u32 fw_size;
 	int i;
 
 	if (!fw || fw->size < sizeof(struct elf32_hdr))

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller
  2026-08-20 14:30 [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading Viken Dadhaniya
  2026-08-20 14:30 ` [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison Viken Dadhaniya
  2026-08-20 14:30 ` [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around Viken Dadhaniya
@ 2026-08-20 14:31 ` Viken Dadhaniya
  2026-08-20 14:44   ` Konrad Dybcio
  2026-08-20 14:31 ` [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer Viken Dadhaniya
  3 siblings, 1 reply; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-20 14:31 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Viken Dadhaniya, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

fw_end was computed from the raw fw_size_in_items, before the odd-word
round-up. A segment with an odd word count could pass the bounds check
at the unrounded value but then be copied one word past the validated
limit. Move fw_end (and the cfg_{idx,val}_end) calculations to after
the round-up so they always reflect the true copy extent.

The caller geni_load_se_fw() re-read hdr->fw_size_in_items for the
memcpy_toio() length, bypassing the validated and rounded value
established by geni_find_protocol_fw(). Add a fw_size_out output
parameter and use it in the caller.

Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
---
 drivers/soc/qcom/qcom-geni-se.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 54c0a66d6dd6..11ca8223fbcd 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1230,6 +1230,8 @@ EXPORT_SYMBOL_GPL(geni_se_resources_init);
  * @se: Pointer to the serial engine structure.
  * @fw: Pointer to the firmware image.
  * @protocol: Expected serial engine protocol type.
+ * @fw_size_out: Non-NULL output parameter; receives the rounded, validated
+ *               firmware word count on success.
  *
  * Identifies the appropriate firmware image or configuration required for a
  * specific communication protocol instance running on a Qualcomm GENI
@@ -1239,7 +1241,8 @@ EXPORT_SYMBOL_GPL(geni_se_resources_init);
  * Return: pointer to a valid 'struct se_fw_hdr' if found, or NULL otherwise.
  */
 static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct firmware *fw,
-					       enum geni_se_protocol_type protocol)
+					       enum geni_se_protocol_type protocol,
+					       u32 *fw_size_out)
 {
 	struct device *dev = se->dev;
 	const struct elf32_hdr *ehdr;
@@ -1289,11 +1292,6 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 
 		sefw = (struct se_fw_hdr *)(fw->data + phdr->p_offset);
 		fw_size = le16_to_cpu(sefw->fw_size_in_items);
-		fw_end = le16_to_cpu(sefw->fw_offset) + fw_size * sizeof(u32);
-		cfg_idx_end = le16_to_cpu(sefw->cfg_idx_offset) +
-			      le16_to_cpu(sefw->cfg_size_in_items) * sizeof(u8);
-		cfg_val_end = le16_to_cpu(sefw->cfg_val_offset) +
-			      le16_to_cpu(sefw->cfg_size_in_items) * sizeof(u32);
 
 		if (le32_to_cpu(sefw->magic) != SE_MAGIC_NUM || le32_to_cpu(sefw->version) != 1)
 			continue;
@@ -1306,6 +1304,12 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 			sefw->fw_size_in_items = cpu_to_le16(fw_size);
 		}
 
+		fw_end = le16_to_cpu(sefw->fw_offset) + fw_size * sizeof(u32);
+		cfg_idx_end = le16_to_cpu(sefw->cfg_idx_offset) +
+			      le16_to_cpu(sefw->cfg_size_in_items) * sizeof(u8);
+		cfg_val_end = le16_to_cpu(sefw->cfg_val_offset) +
+			      le16_to_cpu(sefw->cfg_size_in_items) * sizeof(u32);
+
 		prog_ram_depth = FIELD_GET(PROG_RAM_DEPTH_MSK,
 					   readl_relaxed(se->base + SE_HW_PARAM_2));
 		if (fw_size >= prog_ram_depth) {
@@ -1320,6 +1324,7 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 			continue;
 		}
 
+		*fw_size_out = fw_size;
 		return sefw;
 	}
 
@@ -1430,11 +1435,11 @@ static int geni_load_se_fw(struct geni_se *se, const struct firmware *fw,
 {
 	const u32 *fw_data, *cfg_val_arr;
 	const u8 *cfg_idx_arr;
-	u32 i, reg_value;
+	u32 i, reg_value, fw_size_in_items;
 	int ret;
 	struct se_fw_hdr *hdr;
 
-	hdr = geni_find_protocol_fw(se, fw, protocol);
+	hdr = geni_find_protocol_fw(se, fw, protocol, &fw_size_in_items);
 	if (!hdr)
 		return -EINVAL;
 
@@ -1511,7 +1516,7 @@ static int geni_load_se_fw(struct geni_se *se, const struct firmware *fw,
 
 	/* Program RAM address space. */
 	memcpy_toio(se->base + SE_GENI_CFG_RAMN, fw_data,
-		    le16_to_cpu(hdr->fw_size_in_items) * sizeof(u32));
+		    fw_size_in_items * sizeof(u32));
 
 	/* Put default values on GENI's output pads. */
 	writel_relaxed(0x1, se->base + GENI_FORCE_DEFAULT_REG);

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer
  2026-08-20 14:30 [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading Viken Dadhaniya
                   ` (2 preceding siblings ...)
  2026-08-20 14:31 ` [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller Viken Dadhaniya
@ 2026-08-20 14:31 ` Viken Dadhaniya
  2026-08-20 14:47   ` Konrad Dybcio
  3 siblings, 1 reply; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-20 14:31 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Viken Dadhaniya, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

geni_find_protocol_fw() casts fw->data to a non-const struct se_fw_hdr
pointer and writes back the rounded-up fw_size value:

        sefw->fw_size_in_items = cpu_to_le16(fw_size);

The firmware subsystem maps the firmware blob read-only. Writing through
the cast pointer causes a level-3 permission fault on AArch64 and
crashes the kernel during driver probe.

The write-back is no longer necessary: the previous commit propagates
the rounded size to the caller via fw_size_out. Remove the write-back
and make sefw (and the hdr pointer in the caller) const-correct.

Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
Cc: stable@vger.kernel.org
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
---
 drivers/soc/qcom/qcom-geni-se.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 11ca8223fbcd..6ac2bdc16984 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1238,17 +1238,17 @@ EXPORT_SYMBOL_GPL(geni_se_resources_init);
  * controller. Validates the firmware size against the hardware PROG_RAM_DEPTH
  * read from SE_HW_PARAM_2.
  *
- * Return: pointer to a valid 'struct se_fw_hdr' if found, or NULL otherwise.
+ * Return: pointer to a valid 'const struct se_fw_hdr' if found, or NULL otherwise.
  */
-static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct firmware *fw,
-					       enum geni_se_protocol_type protocol,
-					       u32 *fw_size_out)
+static const struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct firmware *fw,
+						     enum geni_se_protocol_type protocol,
+						     u32 *fw_size_out)
 {
 	struct device *dev = se->dev;
 	const struct elf32_hdr *ehdr;
 	const struct elf32_phdr *phdrs;
 	const struct elf32_phdr	*phdr;
-	struct se_fw_hdr *sefw;
+	const struct se_fw_hdr *sefw;
 	u32 fw_end, cfg_idx_end, cfg_val_end;
 	u32 prog_ram_depth;
 	u32 fw_size;
@@ -1290,7 +1290,7 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 		if (phdr->p_filesz < sizeof(struct se_fw_hdr))
 			continue;
 
-		sefw = (struct se_fw_hdr *)(fw->data + phdr->p_offset);
+		sefw = (const struct se_fw_hdr *)(fw->data + phdr->p_offset);
 		fw_size = le16_to_cpu(sefw->fw_size_in_items);
 
 		if (le32_to_cpu(sefw->magic) != SE_MAGIC_NUM || le32_to_cpu(sefw->version) != 1)
@@ -1299,10 +1299,8 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const struct
 		if (le16_to_cpu(sefw->serial_protocol) != protocol)
 			continue;
 
-		if (fw_size % 2 != 0) {
+		if (fw_size % 2 != 0)
 			fw_size++;
-			sefw->fw_size_in_items = cpu_to_le16(fw_size);
-		}
 
 		fw_end = le16_to_cpu(sefw->fw_offset) + fw_size * sizeof(u32);
 		cfg_idx_end = le16_to_cpu(sefw->cfg_idx_offset) +
@@ -1437,15 +1435,15 @@ static int geni_load_se_fw(struct geni_se *se, const struct firmware *fw,
 	const u8 *cfg_idx_arr;
 	u32 i, reg_value, fw_size_in_items;
 	int ret;
-	struct se_fw_hdr *hdr;
+	const struct se_fw_hdr *hdr;
 
 	hdr = geni_find_protocol_fw(se, fw, protocol, &fw_size_in_items);
 	if (!hdr)
 		return -EINVAL;
 
-	fw_data = (const u32 *)((u8 *)hdr + le16_to_cpu(hdr->fw_offset));
+	fw_data = (const u32 *)((const u8 *)hdr + le16_to_cpu(hdr->fw_offset));
 	cfg_idx_arr = (const u8 *)hdr + le16_to_cpu(hdr->cfg_idx_offset);
-	cfg_val_arr = (const u32 *)((u8 *)hdr + le16_to_cpu(hdr->cfg_val_offset));
+	cfg_val_arr = (const u32 *)((const u8 *)hdr + le16_to_cpu(hdr->cfg_val_offset));
 
 	ret = geni_icc_set_bw(se);
 	if (ret)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison
  2026-08-20 14:30 ` [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison Viken Dadhaniya
@ 2026-08-20 14:40   ` Konrad Dybcio
  0 siblings, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-08-20 14:40 UTC (permalink / raw)
  To: Viken Dadhaniya, Bjorn Andersson, Konrad Dybcio, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

On 8/20/26 4:30 PM, Viken Dadhaniya wrote:
> serial_protocol is declared as __le16 in struct se_fw_hdr, but was
> decoded with le32_to_cpu(). On big-endian systems the extra byte swap
> causes the field to always compare unequal to the protocol argument,
> so no firmware segment is ever selected.
> 
> Use le16_to_cpu() to match the field width.
> 
> Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around
  2026-08-20 14:30 ` [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around Viken Dadhaniya
@ 2026-08-20 14:40   ` Konrad Dybcio
  0 siblings, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-08-20 14:40 UTC (permalink / raw)
  To: Viken Dadhaniya, Bjorn Andersson, Konrad Dybcio, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

On 8/20/26 4:30 PM, Viken Dadhaniya wrote:
> fw_size is read from the 16-bit fw_size_in_items field and incremented
> when the count is odd. If fw_size_in_items == 0xffff the increment
> wraps to 0 as a u16, making the bounds check below pass for a firmware
> segment whose actual size was not validated. Widen fw_size to u32 so
> the increment never wraps.
> 
> Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller
  2026-08-20 14:31 ` [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller Viken Dadhaniya
@ 2026-08-20 14:44   ` Konrad Dybcio
  0 siblings, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-08-20 14:44 UTC (permalink / raw)
  To: Viken Dadhaniya, Bjorn Andersson, Konrad Dybcio, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

On 8/20/26 4:31 PM, Viken Dadhaniya wrote:
> fw_end was computed from the raw fw_size_in_items, before the odd-word
> round-up. A segment with an odd word count could pass the bounds check
> at the unrounded value but then be copied one word past the validated
> limit. Move fw_end (and the cfg_{idx,val}_end) calculations to after
> the round-up so they always reflect the true copy extent.
> 
> The caller geni_load_se_fw() re-read hdr->fw_size_in_items for the
> memcpy_toio() length, bypassing the validated and rounded value
> established by geni_find_protocol_fw(). Add a fw_size_out output
> parameter and use it in the caller.
> 
> Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer
  2026-08-20 14:31 ` [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer Viken Dadhaniya
@ 2026-08-20 14:47   ` Konrad Dybcio
  2026-08-21  6:37     ` Viken Dadhaniya
  0 siblings, 1 reply; 10+ messages in thread
From: Konrad Dybcio @ 2026-08-20 14:47 UTC (permalink / raw)
  To: Viken Dadhaniya, Bjorn Andersson, Konrad Dybcio, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable

On 8/20/26 4:31 PM, Viken Dadhaniya wrote:
> geni_find_protocol_fw() casts fw->data to a non-const struct se_fw_hdr
> pointer and writes back the rounded-up fw_size value:
> 
>         sefw->fw_size_in_items = cpu_to_le16(fw_size);
> 
> The firmware subsystem maps the firmware blob read-only. Writing through
> the cast pointer causes a level-3 permission fault on AArch64 and
> crashes the kernel during driver probe.
> 
> The write-back is no longer necessary: the previous commit propagates

"the previous commit" is discouraged because it's not guaranteed they
land together

> the rounded size to the caller via fw_size_out. Remove the write-back
> and make sefw (and the hdr pointer in the caller) const-correct.
> 
> Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
> ---

apart from that:

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer
  2026-08-20 14:47   ` Konrad Dybcio
@ 2026-08-21  6:37     ` Viken Dadhaniya
  0 siblings, 0 replies; 10+ messages in thread
From: Viken Dadhaniya @ 2026-08-21  6:37 UTC (permalink / raw)
  To: Konrad Dybcio, Bjorn Andersson, Konrad Dybcio, Mukesh Kumar Savaliya
  Cc: linux-arm-msm, linux-kernel, stable



On 8/20/2026 8:17 PM, Konrad Dybcio wrote:
> On 8/20/26 4:31 PM, Viken Dadhaniya wrote:
>> geni_find_protocol_fw() casts fw->data to a non-const struct se_fw_hdr
>> pointer and writes back the rounded-up fw_size value:
>>
>>         sefw->fw_size_in_items = cpu_to_le16(fw_size);
>>
>> The firmware subsystem maps the firmware blob read-only. Writing through
>> the cast pointer causes a level-3 permission fault on AArch64 and
>> crashes the kernel during driver probe.
>>
>> The write-back is no longer necessary: the previous commit propagates
> 
> "the previous commit" is discouraged because it's not guaranteed they
> land together
> 

Updated in v3.

>> the rounded size to the caller via fw_size_out. Remove the write-back
>> and make sefw (and the hdr pointer in the caller) const-correct.
>>
>> Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
>> ---
> 
> apart from that:
> 
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> 
> Konrad


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-08-21  6:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-20 14:30 [PATCH v2 0/4] Fix endian, overflow, and write-protection bugs in SE firmware loading Viken Dadhaniya
2026-08-20 14:30 ` [PATCH v2 1/4] soc: qcom: geni-se: Fix endian conversion for serial_protocol comparison Viken Dadhaniya
2026-08-20 14:40   ` Konrad Dybcio
2026-08-20 14:30 ` [PATCH v2 2/4] soc: qcom: geni-se: Widen fw_size to u32 to prevent wrap-around Viken Dadhaniya
2026-08-20 14:40   ` Konrad Dybcio
2026-08-20 14:31 ` [PATCH v2 3/4] soc: qcom: geni-se: Fix fw_end computed before round-up; propagate size to caller Viken Dadhaniya
2026-08-20 14:44   ` Konrad Dybcio
2026-08-20 14:31 ` [PATCH v2 4/4] soc: qcom: geni-se: Fix write to read-only firmware buffer Viken Dadhaniya
2026-08-20 14:47   ` Konrad Dybcio
2026-08-21  6:37     ` Viken Dadhaniya

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®