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-next>] [day] [month] [year] [list]
Message-Id: <1434102620-2564-1-git-send-email-sudipm.mukherjee@gmail.com>
Date:	Fri, 12 Jun 2015 15:20:20 +0530
From:	Sudip Mukherjee <sudipm.mukherjee@...il.com>
To:	gregkh@...uxfoundation.org
Cc:	linux-kernel@...r.kernel.org,
	Sudip Mukherjee <sudipm.mukherjee@...il.com>
Subject: [PATCH] parport: check exclusive access before register

As of now we were starting the registration process and after the device
is registered we were checking if the device can be used by the
parport. Now lets check it first so that we do not need to go through
the registration process only to fail at the end.
The original exclusive access check at the end is still there so that we
do not get any surprises if two different process registers its device
with same parport and with exclusive access at the same time.

Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>
---

Hi Greg,
One doubt - if anyone sends any patch regarding parport, it will be
addressed to me. so do i need to forward it to you?

 drivers/parport/share.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 697c6d7..8067f54 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -708,6 +708,20 @@ parport_register_device(struct parport *port, const char *name,
 		}
 	}
 
+	if (flags & PARPORT_DEV_EXCL) {
+		if (port->physport->devices) {
+			/*
+			 * If a device is already registered and this new
+			 * device wants exclusive access, then no need to
+			 * continue as we can not grant exclusive access to
+			 * this device.
+			 */
+			pr_err("%s: cannot grant exclusive access for device %s\n",
+			       port->name, name);
+			return NULL;
+		}
+	}
+
 	/* We up our own module reference count, and that of the port
            on which a device is to be registered, to ensure that
            neither of us gets unloaded while we sleep in (e.g.)
@@ -827,6 +841,20 @@ parport_register_dev_model(struct parport *port, const char *name,
 		}
 	}
 
+	if (par_dev_cb->flags & PARPORT_DEV_EXCL) {
+		if (port->physport->devices) {
+			/*
+			 * If a device is already registered and this new
+			 * device wants exclusive access, then no need to
+			 * continue as we can not grant exclusive access to
+			 * this device.
+			 */
+			pr_err("%s: cannot grant exclusive access for device %s\n",
+			       port->name, name);
+			return NULL;
+		}
+	}
+
 	if (!try_module_get(port->ops->owner))
 		return NULL;
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ