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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250506125133.108786-2-nicolescu.roxana@protonmail.com>
Date: Tue, 06 May 2025 12:51:42 +0000
From: Roxana Nicolescu <nicolescu.roxana@...tonmail.com>
To: gregkh@...uxfoundation.org, rafael@...nel.org, dakr@...nel.org, jason.wessel@...driver.com, danielt@...nel.org, dianders@...omium.org, jirislaby@...nel.org
Cc: kgdb-bugreport@...ts.sourceforge.net, linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org, skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev
Subject: [RFC PATCH 1/2] driver core: faux: create the device if probe() is deferred too

There are situations when the faux device is probed, it waits for the
availability for another piece of hardware. In case this dependency is not
available, it can return -EPROBE_DEFER and probe will be retried later.
But, with the current implementation, probe won't be retried at all
because we destroyed the faux device in case probe did not return 0 and
therefore the device is binded to the driver.

To solve this, the faux device creation fails only when probe failed with
something other than -EPROBE_DEFER. In order to achieve this, a boolean
var is used in struct faux_object.

Signed-off-by: Roxana Nicolescu <nicolescu.roxana@...tonmail.com>
---
 drivers/base/faux.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index 407c1d1aad50..21e385631872 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -25,6 +25,7 @@
 struct faux_object {
 	struct faux_device faux_dev;
 	const struct faux_device_ops *faux_ops;
+	bool probe_successed_or_deferred;
 };
 #define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev)
 
@@ -48,6 +49,8 @@ static int faux_probe(struct device *dev)
 	if (faux_ops && faux_ops->probe)
 		ret = faux_ops->probe(faux_dev);
 
+	faux_obj->probe_successed_or_deferred = !ret || ret == -EPROBE_DEFER;
+
 	return ret;
 }
 
@@ -150,12 +153,13 @@ struct faux_device *faux_device_create_with_groups(const char *name,
 	}
 
 	/*
-	 * Verify that we did bind the driver to the device (i.e. probe worked),
+	 * Verify that we either did bind the driver to the device (i.e. probe worked),
+	 * or probe is deferred and tried later,
 	 * if not, let's fail the creation as trying to guess if probe was
 	 * successful is almost impossible to determine by the caller.
 	 */
-	if (!dev->driver) {
-		dev_err(dev, "probe did not succeed, tearing down the device\n");
+	if (!faux_obj->probe_successed_or_deferred) {
+		dev_err(dev, "probe did not succeed and it's not deferred, tearing down the device\n");
 		faux_device_destroy(faux_dev);
 		faux_dev = NULL;
 	}
-- 
2.34.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ