aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/slot.c6
-rw-r--r--fs/fuse/cuse.c4
-rw-r--r--fs/ocfs2/cluster/sys.c2
-rw-r--r--fs/ocfs2/stackglue.c8
-rw-r--r--include/linux/kernel.h8
-rw-r--r--include/linux/moduleparam.h8
-rw-r--r--include/linux/sysfs.h3
7 files changed, 23 insertions, 16 deletions
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 7dd62fa9d0bd..396c200b9ddb 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -116,11 +116,11 @@ static void pci_slot_release(struct kobject *kobj)
116} 116}
117 117
118static struct pci_slot_attribute pci_slot_attr_address = 118static struct pci_slot_attribute pci_slot_attr_address =
119 __ATTR(address, (S_IFREG | S_IRUGO), address_read_file, NULL); 119 __ATTR(address, S_IRUGO, address_read_file, NULL);
120static struct pci_slot_attribute pci_slot_attr_max_speed = 120static struct pci_slot_attribute pci_slot_attr_max_speed =
121 __ATTR(max_bus_speed, (S_IFREG | S_IRUGO), max_speed_read_file, NULL); 121 __ATTR(max_bus_speed, S_IRUGO, max_speed_read_file, NULL);
122static struct pci_slot_attribute pci_slot_attr_cur_speed = 122static struct pci_slot_attribute pci_slot_attr_cur_speed =
123 __ATTR(cur_bus_speed, (S_IFREG | S_IRUGO), cur_speed_read_file, NULL); 123 __ATTR(cur_bus_speed, S_IRUGO, cur_speed_read_file, NULL);
124 124
125static struct attribute *pci_slot_default_attrs[] = { 125static struct attribute *pci_slot_default_attrs[] = {
126 &pci_slot_attr_address.attr, 126 &pci_slot_attr_address.attr,
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index b96a49b37d66..77cf5eeeabd1 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -568,7 +568,7 @@ static ssize_t cuse_class_waiting_show(struct device *dev,
568 568
569 return sprintf(buf, "%d\n", atomic_read(&cc->fc.num_waiting)); 569 return sprintf(buf, "%d\n", atomic_read(&cc->fc.num_waiting));
570} 570}
571static DEVICE_ATTR(waiting, S_IFREG | 0400, cuse_class_waiting_show, NULL); 571static DEVICE_ATTR(waiting, 0400, cuse_class_waiting_show, NULL);
572 572
573static ssize_t cuse_class_abort_store(struct device *dev, 573static ssize_t cuse_class_abort_store(struct device *dev,
574 struct device_attribute *attr, 574 struct device_attribute *attr,
@@ -579,7 +579,7 @@ static ssize_t cuse_class_abort_store(struct device *dev,
579 fuse_abort_conn(&cc->fc); 579 fuse_abort_conn(&cc->fc);
580 return count; 580 return count;
581} 581}
582static DEVICE_ATTR(abort, S_IFREG | 0200, NULL, cuse_class_abort_store); 582static DEVICE_ATTR(abort, 0200, NULL, cuse_class_abort_store);
583 583
584static struct attribute *cuse_class_dev_attrs[] = { 584static struct attribute *cuse_class_dev_attrs[] = {
585 &dev_attr_waiting.attr, 585 &dev_attr_waiting.attr,
diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c
index a4b07730b2e1..b7f57271d49c 100644
--- a/fs/ocfs2/cluster/sys.c
+++ b/fs/ocfs2/cluster/sys.c
@@ -41,7 +41,7 @@ static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr,
41 return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION); 41 return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
42} 42}
43static struct kobj_attribute attr_version = 43static struct kobj_attribute attr_version =
44 __ATTR(interface_revision, S_IFREG | S_IRUGO, version_show, NULL); 44 __ATTR(interface_revision, S_IRUGO, version_show, NULL);
45 45
46static struct attribute *o2cb_attrs[] = { 46static struct attribute *o2cb_attrs[] = {
47 &attr_version.attr, 47 &attr_version.attr,
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 1324e6600e57..25e9f7b5bad3 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -494,7 +494,7 @@ static ssize_t ocfs2_max_locking_protocol_show(struct kobject *kobj,
494} 494}
495 495
496static struct kobj_attribute ocfs2_attr_max_locking_protocol = 496static struct kobj_attribute ocfs2_attr_max_locking_protocol =
497 __ATTR(max_locking_protocol, S_IFREG | S_IRUGO, 497 __ATTR(max_locking_protocol, S_IRUGO,
498 ocfs2_max_locking_protocol_show, NULL); 498 ocfs2_max_locking_protocol_show, NULL);
499 499
500static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj, 500static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj,
@@ -526,7 +526,7 @@ static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj,
526} 526}
527 527
528static struct kobj_attribute ocfs2_attr_loaded_cluster_plugins = 528static struct kobj_attribute ocfs2_attr_loaded_cluster_plugins =
529 __ATTR(loaded_cluster_plugins, S_IFREG | S_IRUGO, 529 __ATTR(loaded_cluster_plugins, S_IRUGO,
530 ocfs2_loaded_cluster_plugins_show, NULL); 530 ocfs2_loaded_cluster_plugins_show, NULL);
531 531
532static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj, 532static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj,
@@ -548,7 +548,7 @@ static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj,
548} 548}
549 549
550static struct kobj_attribute ocfs2_attr_active_cluster_plugin = 550static struct kobj_attribute ocfs2_attr_active_cluster_plugin =
551 __ATTR(active_cluster_plugin, S_IFREG | S_IRUGO, 551 __ATTR(active_cluster_plugin, S_IRUGO,
552 ocfs2_active_cluster_plugin_show, NULL); 552 ocfs2_active_cluster_plugin_show, NULL);
553 553
554static ssize_t ocfs2_cluster_stack_show(struct kobject *kobj, 554static ssize_t ocfs2_cluster_stack_show(struct kobject *kobj,
@@ -597,7 +597,7 @@ static ssize_t ocfs2_cluster_stack_store(struct kobject *kobj,
597 597
598 598
599static struct kobj_attribute ocfs2_attr_cluster_stack = 599static struct kobj_attribute ocfs2_attr_cluster_stack =
600 __ATTR(cluster_stack, S_IFREG | S_IRUGO | S_IWUSR, 600 __ATTR(cluster_stack, S_IRUGO | S_IWUSR,
601 ocfs2_cluster_stack_show, 601 ocfs2_cluster_stack_show,
602 ocfs2_cluster_stack_store); 602 ocfs2_cluster_stack_store);
603 603
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 471090093c67..4679eddc110a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -842,4 +842,12 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
842# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 842# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
843#endif 843#endif
844 844
845/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
846#define VERIFY_OCTAL_PERMISSIONS(perms) \
847 (BUILD_BUG_ON_ZERO((perms) < 0) + \
848 BUILD_BUG_ON_ZERO((perms) > 0777) + \
849 /* User perms >= group perms >= other perms */ \
850 BUILD_BUG_ON_ZERO(((perms) >> 6) < (((perms) >> 3) & 7)) + \
851 BUILD_BUG_ON_ZERO((((perms) >> 3) & 7) < ((perms) & 7)) + \
852 (perms))
845#endif 853#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 175f6995d1af..204a67743804 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -186,14 +186,12 @@ struct kparam_array
186 parameters. */ 186 parameters. */
187#define __module_param_call(prefix, name, ops, arg, perm, level) \ 187#define __module_param_call(prefix, name, ops, arg, perm, level) \
188 /* Default value instead of permissions? */ \ 188 /* Default value instead of permissions? */ \
189 static int __param_perm_check_##name __attribute__((unused)) = \ 189 static const char __param_str_##name[] = prefix #name; \
190 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
191 + BUILD_BUG_ON_ZERO(sizeof(""prefix) > MAX_PARAM_PREFIX_LEN); \
192 static const char __param_str_##name[] = prefix #name; \
193 static struct kernel_param __moduleparam_const __param_##name \ 190 static struct kernel_param __moduleparam_const __param_##name \
194 __used \ 191 __used \
195 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ 192 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
196 = { __param_str_##name, ops, perm, level, { arg } } 193 = { __param_str_##name, ops, VERIFY_OCTAL_PERMISSIONS(perm), \
194 level, { arg } }
197 195
198/* Obsolete - use module_param_cb() */ 196/* Obsolete - use module_param_cb() */
199#define module_param_call(name, set, get, arg, perm) \ 197#define module_param_call(name, set, get, arg, perm) \
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 30b2ebee6439..f517e6e488c8 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -71,7 +71,8 @@ struct attribute_group {
71 */ 71 */
72 72
73#define __ATTR(_name, _mode, _show, _store) { \ 73#define __ATTR(_name, _mode, _show, _store) { \
74 .attr = {.name = __stringify(_name), .mode = _mode }, \ 74 .attr = {.name = __stringify(_name), \
75 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
75 .show = _show, \ 76 .show = _show, \
76 .store = _store, \ 77 .store = _store, \
77} 78}