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] [day] [month] [year] [list]
Message-ID: <20251107154426.2116743-2-Sergey.Nalivayko@kaspersky.com>
Date: Fri, 7 Nov 2025 18:44:25 +0300
From: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>
To: <linux-media@...r.kernel.org>
CC: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>,
	<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>, Mauro
 Carvalho Chehab <mchehab@...nel.org>, Michael Krufky <mkrufky@...uxtv.org>
Subject: [PATCH 1/2] media: dvb-usb-v2: add device init_ready flag

The current implementation of dvb-usb-v2 initializes device in
dvb_usbv2_probe() while making it immediately available for use in the I2C,
Remote Control, demux and potentially other kernel subsystems before
the driver has fully completed initialization. As a result, the device
becomes accessible through these subsystem interfaces prematurely,
allowing to invoke read/write operations on the device before it is
fully initialized.

Introduce an atomic init_ready flag in struct dvb_usb_device for
the DVB-USB-V2 driver.

Allow driver code to check this flag before performing actions
that access device state (for example I2C reads) which may race
with device initialization.

Signed-off-by: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>
---
 drivers/media/usb/dvb-usb-v2/dvb_usb.h      | 3 +++
 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
index ecdc20d45132..ecb929e006ba 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
@@ -389,6 +389,9 @@ struct dvb_usb_device {
 	struct mutex i2c_mutex;
 	struct i2c_adapter i2c_adap;
 
+	/* Check in drivers to prevent read from uninitialized device */
+	atomic_t init_ready;
+
 	struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
 
 	/* remote control */
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
index f1c79f351ec8..d1cd68f242cc 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -988,6 +988,8 @@ int dvb_usbv2_probe(struct usb_interface *intf,
 exit:
 	usb_set_intfdata(intf, d);
 
+	atomic_set(&d->init_ready, 1);
+
 	return 0;
 err_free_all:
 	dvb_usbv2_exit(d);
@@ -1012,6 +1014,8 @@ void dvb_usbv2_disconnect(struct usb_interface *intf)
 	dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__,
 			intf->cur_altsetting->desc.bInterfaceNumber);
 
+	atomic_set(&d->init_ready, 0);
+
 	if (d->props->exit)
 		d->props->exit(d);
 
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ