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: <47CED9A3.2050508@openvz.org>
Date:	Wed, 05 Mar 2008 20:34:27 +0300
From:	Pavel Emelyanov <xemul@...nvz.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Paul Menage <menage@...gle.com>,
	Sukadev Bhattiprolu <sukadev@...ibm.com>,
	Serge Hallyn <serue@...ibm.com>
Subject: [PATCH 4/9] Make kobj_lookup() return the mapping's permissions

The kobj_lookup() searches the kobject by its dev_t. Since this
mapping is going to be restricted with permissions, make the
kobj_lookup() return the mapping's permissions.

Currently the mode returned is unused.

Signed-off-by: Pavel Emelyanov <xemul@...nvz.org>

---
 block/genhd.c            |    4 ++--
 drivers/base/map.c       |    8 ++++++--
 fs/block_dev.c           |    3 ++-
 fs/char_dev.c            |    4 +++-
 include/linux/genhd.h    |    2 +-
 include/linux/kobj_map.h |    2 +-
 6 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 9a7a903..1d1d0f2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -210,12 +210,12 @@ void unlink_gendisk(struct gendisk *disk)
  * This function gets the structure containing partitioning
  * information for the given device @dev.
  */
-struct gendisk *get_gendisk(dev_t devt, int *part)
+struct gendisk *get_gendisk(dev_t devt, mode_t *mode, int *part)
 {
 	struct kobject *kobj;
 	struct device *dev;
 
-	kobj = kobj_lookup(bdev_map, devt, part);
+	kobj = kobj_lookup(bdev_map, devt, mode, part);
 	if (kobj == NULL)
 		return NULL;
 
diff --git a/drivers/base/map.c b/drivers/base/map.c
index c7e28a1..285a2d2 100644
--- a/drivers/base/map.c
+++ b/drivers/base/map.c
@@ -117,7 +117,8 @@ void kobj_unmap(struct kobj_map *domain, dev_t dev, unsigned long range)
 	kfree(found);
 }
 
-struct kobject *kobj_lookup(struct kobj_map *domain, dev_t dev, int *index)
+struct kobject *kobj_lookup(struct kobj_map *domain, dev_t dev, mode_t *mode,
+		int *index)
 {
 	struct kobject *kobj;
 	struct probe *p;
@@ -149,8 +150,11 @@ retry:
 		kobj = probe(dev, index, data);
 		/* Currently ->owner protects _only_ ->probe() itself. */
 		module_put(owner);
-		if (kobj)
+		if (kobj) {
+			if (mode)
+				*mode = p->mode;
 			return kobj;
+		}
 		goto retry;
 	}
 	mutex_unlock(domain->lock);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index a0e9596..00dda91 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -934,11 +934,12 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
 	struct module *owner = NULL;
 	struct gendisk *disk;
 	int ret = -ENXIO;
+	mode_t mode;
 	int part;
 
 	file->f_mapping = bdev->bd_inode->i_mapping;
 	lock_kernel();
-	disk = get_gendisk(bdev->bd_dev, &part);
+	disk = get_gendisk(bdev->bd_dev, &mode, &part);
 	if (!disk) {
 		unlock_kernel();
 		bdput(bdev);
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 68e510b..dceb579 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -367,8 +367,10 @@ static int chrdev_open(struct inode *inode, struct file *filp)
 	if (!p) {
 		struct kobject *kobj;
 		int idx;
+		mode_t mode;
+
 		spin_unlock(&cdev_lock);
-		kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
+		kobj = kobj_lookup(cdev_map, inode->i_rdev, &mode, &idx);
 		if (!kobj)
 			return -ENXIO;
 		new = container_of(kobj, struct cdev, kobj);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 09a3b18..e09df44 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -371,7 +371,7 @@ extern int get_blkdev_list(char *, int);
 extern void add_disk(struct gendisk *disk);
 extern void del_gendisk(struct gendisk *gp);
 extern void unlink_gendisk(struct gendisk *gp);
-extern struct gendisk *get_gendisk(dev_t dev, int *part);
+extern struct gendisk *get_gendisk(dev_t dev, mode_t *mode, int *part);
 
 extern void set_device_ro(struct block_device *bdev, int flag);
 extern void set_disk_ro(struct gendisk *disk, int flag);
diff --git a/include/linux/kobj_map.h b/include/linux/kobj_map.h
index bafe178..867f307 100644
--- a/include/linux/kobj_map.h
+++ b/include/linux/kobj_map.h
@@ -8,7 +8,7 @@ struct kobj_map;
 int kobj_map(struct kobj_map *, dev_t, unsigned long, struct module *,
 	     kobj_probe_t *, int (*)(dev_t, void *), void *);
 void kobj_unmap(struct kobj_map *, dev_t, unsigned long);
-struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *);
+struct kobject *kobj_lookup(struct kobj_map *, dev_t, mode_t *, int *);
 struct kobj_map *kobj_map_init(kobj_probe_t *, struct mutex *);
 
 #endif
-- 
1.5.3.4

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