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: <b0f1032863818f2834094e2ca9ce4b1c13122748.1226551772.git.michael@ellerman.id.au>
Date:	Thu, 13 Nov 2008 15:49:50 +1100 (EST)
From:	Michael Ellerman <michael@...erman.id.au>
To:	<linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...l.org>, Greg Kroah-Hartman <greg@...ah.com>,
	<viro@...iv.linux.org.uk>
Subject: [PATCH] Store the relevant miscdevice in file->private_data in misc_open()

Currently it's not easy to share file_operations between multiple
instances of a miscdevice. In order to do this, the device code needs to
store a list of all it's miscdevice instances, and when fops->open() is
called, search the list and find the right device based on the minor
number.

However the generic miscdevice code already has a list of miscdevices,
and uses this to find the right device in misc_open(). If misc_open()
would store the miscdevice it found in file->private_data, then the
device code wouldn't need to worry about storing it's own separate list
and searching that as well.

The rest of the miscdevice code does not use file->private_data, so the
device code is still free to use file->private_data for something else
if it wants to.

Signed-off-by: Michael Ellerman <michael@...erman.id.au>

---
I'm not all that across VFS or driver core stuff, but this looks safe to
me, lots of other devices use file->private_data and this should be no
different AFAICT.


 drivers/char/misc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index a5e0db9..bb91d68 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -147,11 +147,13 @@ static int misc_open(struct inode * inode, struct file * file)
 	err = 0;
 	old_fops = file->f_op;
 	file->f_op = new_fops;
+	file->private_data = c;
 	if (file->f_op->open) {
 		err=file->f_op->open(inode,file);
 		if (err) {
 			fops_put(file->f_op);
 			file->f_op = fops_get(old_fops);
+			file->private_data = NULL;
 		}
 	}
 	fops_put(old_fops);
-- 
1.5.5

--
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