aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-07-30 23:54:54 -0400
committerNeilBrown <neilb@suse.de>2014-07-30 23:54:54 -0400
commitaf5628f05db62c656f994b2346897939b5110d6a (patch)
treed3157495b181dbb830fc44375130bde365037a25
parent2446dba03f9dabe0b477a126cbeb377854785b47 (diff)
md: disable probing for md devices 512 and over.
The way md devices are traditionally created in the kernel is simply to open the device with the desired major/minor number. This can be problematic as some support tools, notably udev and programs run by udev, can open a device just to see what is there, and find that it has created something. It is easy for a race to cause udev to open an md device just after it was destroy, causing it to suddenly re-appear. For some time we have had an alternate way to create md devices echo md_somename > /sys/modules/md_mod/paramaters/new_array This will always use a minor number of 512 or higher, which mdadm normally avoids. Using this makes the creation-by-opening unnecessary, but does not disable it, so it is still there to cause problems. This patch disable probing for devices with a major of 9 (MD_MAJOR) and a minor of 512 and up. This devices created by writing to new_array cannot be re-created by opening the node in /dev. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/md.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 32fc19c540d4..1379b1a3b9ff 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8592,7 +8592,7 @@ static int __init md_init(void)
8592 goto err_mdp; 8592 goto err_mdp;
8593 mdp_major = ret; 8593 mdp_major = ret;
8594 8594
8595 blk_register_region(MKDEV(MD_MAJOR, 0), 1UL<<MINORBITS, THIS_MODULE, 8595 blk_register_region(MKDEV(MD_MAJOR, 0), 512, THIS_MODULE,
8596 md_probe, NULL, NULL); 8596 md_probe, NULL, NULL);
8597 blk_register_region(MKDEV(mdp_major, 0), 1UL<<MINORBITS, THIS_MODULE, 8597 blk_register_region(MKDEV(mdp_major, 0), 1UL<<MINORBITS, THIS_MODULE,
8598 md_probe, NULL, NULL); 8598 md_probe, NULL, NULL);
@@ -8687,7 +8687,7 @@ static __exit void md_exit(void)
8687 struct list_head *tmp; 8687 struct list_head *tmp;
8688 int delay = 1; 8688 int delay = 1;
8689 8689
8690 blk_unregister_region(MKDEV(MD_MAJOR,0), 1U << MINORBITS); 8690 blk_unregister_region(MKDEV(MD_MAJOR,0), 512);
8691 blk_unregister_region(MKDEV(mdp_major,0), 1U << MINORBITS); 8691 blk_unregister_region(MKDEV(mdp_major,0), 1U << MINORBITS);
8692 8692
8693 unregister_blkdev(MD_MAJOR,"md"); 8693 unregister_blkdev(MD_MAJOR,"md");