lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251211221040.19870-1-m.lobanov@rosa.ru>
Date: Fri, 12 Dec 2025 01:10:38 +0300
From: Mikhail Lobanov <m.lobanov@...a.ru>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: Mikhail Lobanov <m.lobanov@...a.ru>,
	Bingbu Cao <bingbu.cao@...el.com>,
	Tianshu Qiu <tian.shu.qiu@...el.com>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Hans Verkuil <hverkuil@...nel.org>,
	linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	lvc-project@...uxtesting.org
Subject: [PATCH] media: ipu6: isys: fix csi2 NULL deref in stream enable/disable

media_pad_remote_pad_first() may return NULL when there is no enabled
media link on the CSI-2 sink pad. ipu6_isys_csi2_enable_streams() and
ipu6_isys_csi2_disable_streams() dereference remote_pad->entity
unconditionally, which can lead to a NULL pointer dereference when no
remote pad is present.

Check the remote pad before dereferencing it, return -ENOTCONN from the
enable path when no remote pad is found, and always stop the local CSI-2
stream in the disable path even if the remote entity is already gone.
Rely on this check to also cover the remote sub-device, as
media_entity_to_v4l2_subdev() only returns NULL when called with a NULL
entity.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 3a5c59ad926b ("media: ipu6: Rework CSI-2 sub-device streaming control")
Signed-off-by: Mikhail Lobanov <m.lobanov@...a.ru>
---
 drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
index 43a2a16a3c2a..29791b66d479 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c
@@ -356,6 +356,9 @@ static int ipu6_isys_csi2_enable_streams(struct v4l2_subdev *sd,
 	int ret;
 
 	remote_pad = media_pad_remote_pad_first(&sd->entity.pads[CSI2_PAD_SINK]);
+	if (!remote_pad)
+		return -ENOTCONN;
+
 	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
 
 	sink_streams =
@@ -393,6 +396,11 @@ static int ipu6_isys_csi2_disable_streams(struct v4l2_subdev *sd,
 						&streams_mask);
 
 	remote_pad = media_pad_remote_pad_first(&sd->entity.pads[CSI2_PAD_SINK]);
+	if (!remote_pad) {
+		ipu6_isys_csi2_set_stream(sd, NULL, 0, false);
+		return 0;
+	}
+
 	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
 
 	ipu6_isys_csi2_set_stream(sd, NULL, 0, false);
-- 
2.47.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ