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]
Date:	Tue, 26 Jul 2011 17:48:06 +0200
From:	Kay Sievers <kay.sievers@...y.org>
To:	Zdenek Kabelac <zkabelac@...hat.com>
Cc:	device-mapper development <dm-devel@...hat.com>,
	Greg KH <greg@...ah.com>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [dm-devel] [PATCH] Reduce number of KOBJ_REMOVE events

On Mon, 2011-07-25 at 16:22 +0200, Kay Sievers wrote:
> On Mon, Jul 25, 2011 at 14:54, Zdenek Kabelac <zkabelac@...hat.com> wrote:
> > Dne 25.7.2011 14:17, Kay Sievers napsal(a):
> 
> >>>> Then have 'dm_blk_dops' add '.uevent' and let the core call into the dm
> >>>> code to the needed properties to the 'remove' event, instead of sending
> >>>> its own, and see the duplication.
> >>>
> >>> Sounds like complex solution
> >>
> >> I don't think so, It's clean, ~30 lines long, and technically correct, I expect.
> 
> In include/linux/blkdev.h add:
>   int (*uevent) (struct gendisk *, struct kobj_uevent_env *env);
> to
>   struct block_device_operations
> 
> In block/genhd.c add:
>   .uevent = block_uevent;
> to
>   struct class block_class
> and have the block_uevent() callback check for an existing uevent() in
> the block_device_operations, call it when it's specified.
> 
> In drivers/md/dm.c add:
>   .dm_uevent;
> to
>   struct block_device_operations dm_blk_dops
> and add all the needed variables there, instead of sending out a faked
> device 'remove' event.

Here is the code to illustrate, and fix the issue of needing to send any
'remove' for a device from a driver.

Thanks,
Kay


diff --git a/block/genhd.c b/block/genhd.c
index 6024b82..c2e9714 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1097,8 +1097,21 @@ static void disk_release(struct device *dev)
 	free_part_info(&disk->part0);
 	kfree(disk);
 }
+
+static int block_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+	struct gendisk *disk = dev_to_disk(dev);
+
+	if (!disk->fops)
+		return 0;
+	if (disk->fops->uevent)
+		return disk->fops->uevent(disk, env);
+	return 0;
+}
+
 struct class block_class = {
 	.name		= "block",
+	.dev_uevent	= block_uevent,
 };
 
 static char *block_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 0cf68b4..22e486e 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2682,11 +2682,17 @@ void dm_free_md_mempools(struct dm_md_mempools *pools)
 	kfree(pools);
 }
 
+static int dm_uevent(struct gendisk *disk, struct kobj_uevent_env *env)
+{
+	return add_uevent_var(env, "COOKIE_MONSTER=1");
+}
+
 static const struct block_device_operations dm_blk_dops = {
 	.open = dm_blk_open,
 	.release = dm_blk_close,
 	.ioctl = dm_blk_ioctl,
 	.getgeo = dm_blk_getgeo,
+	.uevent = dm_uevent,
 	.owner = THIS_MODULE
 };
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1a23722..6dbd69e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1300,6 +1300,7 @@ struct block_device_operations {
 						void **, unsigned long *);
 	unsigned int (*check_events) (struct gendisk *disk,
 				      unsigned int clearing);
+	int (*uevent) (struct gendisk *, struct kobj_uevent_env *env);
 	/* ->media_changed() is DEPRECATED, use ->check_events() instead */
 	int (*media_changed) (struct gendisk *);
 	void (*unlock_native_capacity) (struct gendisk *);


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