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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251217213526.196533-2-m.lobanov@rosa.ru>
Date: Thu, 18 Dec 2025 00:35:22 +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 v2 1/2] media: ipu6: isys: csi2: guard remote pad lookups in stream ops

ipu6_isys_csi2_enable_streams() and ipu6_isys_csi2_disable_streams()
use media_pad_remote_pad_first() on the CSI-2 sink pad and dereference
the returned remote pad unconditionally. media_pad_remote_pad_first()
only returns a pad for an enabled link, and the external subdev -> CSI-2
sink link is created only when the external subdev is successfully bound
in isys_complete_ext_device_registration().

CSI-2 subdevs are registered independently of external devices and are
created with HAS_DEVNODE and STREAMS flags. As a result, the CSI-2 stream
callbacks can be reached even when a given CSI-2 port has no enabled
upstream link, in which case media_pad_remote_pad_first() returns NULL.

Check the remote pad before dereferencing it. Return -ENOTCONN from the
enable path when no remote pad is found. In the disable path, always stop
the local CSI-2 receiver and return success when the remote link is
missing to keep teardown best-effort and consistent with the existing
behaviour (remote disable errors are not propagated today).

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>
---
v1: https://lore.kernel.org/lkml/20251211221040.19870-1-m.lobanov@rosa.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