Skip to contentSkip to conversation

media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings

PATCH Applied Artem Dinaburg 2 participants 2 messages Sep 24 – Sep 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings

From: Hans de Goede <[email protected]>

[ Upstream commit 284be5693163343e1cf17c03917eecd1d6681bcf ]

When ipu_bridge_parse_rotation() and ipu_bridge_parse_orientation() run sensor->adev is not set yet.

So if either of the dev_warn() calls about unknown values are hit this will lead to a NULL pointer deref.

Set sensor->adev earlier, with a borrowed ref to avoid making unrolling on errors harder, to fix this.

Fixes 485aa3df0dff ("media: ipu3-cio2: Parse sensor orientation and rotation")
Cc Fabian Wüthrich <[email protected]>

[ Backport to 6.1.y: apply the sensor adev assignment in this tree's
older ipu3/cio2-bridge.c and cio2_bridge_connect_sensor(). ]

Assisted-by LLM

---
Hi Greg, Sasha, and IPU bridge maintainers,

I am continuing with CVE backports still missing from 6.1.y. This fix is inherited by v6.6 and every later mainline release, but 6.1.y still has the affected code. The target-specific adjustment is described in the bracketed note above.

Could you please queue it for 6.1.y?

Thanks,
Artem Dinaburg

CVE: CVE-2023-53336

Build: This patch was included in an x86_64 allmodconfig and CONFIG_WERROR=y build.
It produced vmlinux and modules with no new warnings or errors.

AI assistance: An LLM helped find, adapt, and validate this backport; I reviewed the patch and test output.

 drivers/media/pci/intel/ipu3/cio2-bridge.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/media/pci/intel/ipu3/cio2-bridge.c +5 -0
index df6c94da2f6ad8..e68b735a150a9d 100644
@@ -280,6 +280,11 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 		}
 
 		sensor = &bridge->sensors[bridge->n_sensors];
+		/*
+		 * Borrow our adev ref to the sensor for now, on success
+		 * acpi_dev_get(adev) is done further below.
+		 */
+		sensor->adev = adev;
 		strscpy(sensor->name, cfg->hid, sizeof(sensor->name));
 
 		ret = cio2_bridge_read_acpi_buffer(adev, "SSDB",
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 2 lines

[ Backport to 6.1.y: apply the sensor adev assignment in this tree's
older ipu3/cio2-bridge.c and cio2_bridge_connect_sensor(). ]

Queued for 6.1, thanks.

Signature · 2 lines
Thanks,
Sasha