diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-09-18 17:01:12 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 15:50:38 -0400 |
commit | e454cea20bdcff10ee698d11b8882662a0153a47 (patch) | |
tree | f44581fe57787aef0a4f4dc00993a90ea8e688f6 /drivers/char/mem.c | |
parent | 78f28b7c555359c67c2a0d23f7436e915329421e (diff) |
Driver-Core: extend devnode callbacks to provide permissions
This allows subsytems to provide devtmpfs with non-default permissions
for the device node. Instead of the default mode of 0600, null, zero,
random, urandom, full, tty, ptmx now have a mode of 0666, which allows
non-privileged processes to access standard device nodes in case no
other userspace process applies the expected permissions.
This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r-- | drivers/char/mem.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 0491cdf63f2a..0aede1d6a9ea 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -866,24 +866,25 @@ static const struct file_operations kmsg_fops = { | |||
866 | 866 | ||
867 | static const struct memdev { | 867 | static const struct memdev { |
868 | const char *name; | 868 | const char *name; |
869 | mode_t mode; | ||
869 | const struct file_operations *fops; | 870 | const struct file_operations *fops; |
870 | struct backing_dev_info *dev_info; | 871 | struct backing_dev_info *dev_info; |
871 | } devlist[] = { | 872 | } devlist[] = { |
872 | [ 1] = { "mem", &mem_fops, &directly_mappable_cdev_bdi }, | 873 | [1] = { "mem", 0, &mem_fops, &directly_mappable_cdev_bdi }, |
873 | #ifdef CONFIG_DEVKMEM | 874 | #ifdef CONFIG_DEVKMEM |
874 | [ 2] = { "kmem", &kmem_fops, &directly_mappable_cdev_bdi }, | 875 | [2] = { "kmem", 0, &kmem_fops, &directly_mappable_cdev_bdi }, |
875 | #endif | 876 | #endif |
876 | [ 3] = {"null", &null_fops, NULL }, | 877 | [3] = { "null", 0666, &null_fops, NULL }, |
877 | #ifdef CONFIG_DEVPORT | 878 | #ifdef CONFIG_DEVPORT |
878 | [ 4] = { "port", &port_fops, NULL }, | 879 | [4] = { "port", 0, &port_fops, NULL }, |
879 | #endif | 880 | #endif |
880 | [ 5] = { "zero", &zero_fops, &zero_bdi }, | 881 | [5] = { "zero", 0666, &zero_fops, &zero_bdi }, |
881 | [ 7] = { "full", &full_fops, NULL }, | 882 | [7] = { "full", 0666, &full_fops, NULL }, |
882 | [ 8] = { "random", &random_fops, NULL }, | 883 | [8] = { "random", 0666, &random_fops, NULL }, |
883 | [ 9] = { "urandom", &urandom_fops, NULL }, | 884 | [9] = { "urandom", 0666, &urandom_fops, NULL }, |
884 | [11] = { "kmsg", &kmsg_fops, NULL }, | 885 | [11] = { "kmsg", 0, &kmsg_fops, NULL }, |
885 | #ifdef CONFIG_CRASH_DUMP | 886 | #ifdef CONFIG_CRASH_DUMP |
886 | [12] = { "oldmem", &oldmem_fops, NULL }, | 887 | [12] = { "oldmem", 0, &oldmem_fops, NULL }, |
887 | #endif | 888 | #endif |
888 | }; | 889 | }; |
889 | 890 | ||
@@ -920,6 +921,13 @@ static const struct file_operations memory_fops = { | |||
920 | .open = memory_open, | 921 | .open = memory_open, |
921 | }; | 922 | }; |
922 | 923 | ||
924 | static char *mem_devnode(struct device *dev, mode_t *mode) | ||
925 | { | ||
926 | if (mode && devlist[MINOR(dev->devt)].mode) | ||
927 | *mode = devlist[MINOR(dev->devt)].mode; | ||
928 | return NULL; | ||
929 | } | ||
930 | |||
923 | static struct class *mem_class; | 931 | static struct class *mem_class; |
924 | 932 | ||
925 | static int __init chr_dev_init(void) | 933 | static int __init chr_dev_init(void) |
@@ -935,6 +943,7 @@ static int __init chr_dev_init(void) | |||
935 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); | 943 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); |
936 | 944 | ||
937 | mem_class = class_create(THIS_MODULE, "mem"); | 945 | mem_class = class_create(THIS_MODULE, "mem"); |
946 | mem_class->devnode = mem_devnode; | ||
938 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { | 947 | for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { |
939 | if (!devlist[minor].name) | 948 | if (!devlist[minor].name) |
940 | continue; | 949 | continue; |