diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-13 21:03:50 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-13 21:23:57 -0400 |
commit | de5109898a8a0cb001abcb6916bef4efa32bf39b (patch) | |
tree | 458943406396cf7904b23ecd0bff7169c29b69a8 | |
parent | f92201c34885cf0da5403c6959bc9bcd9a648963 (diff) |
samples/kobject/: avoid world-writable sysfs files.
In line with practice for module parameters, we're adding a build-time
check that sysfs files aren't world-writable.
Cc: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | samples/kobject/kobject-example.c | 7 | ||||
-rw-r--r-- | samples/kobject/kset-example.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c index 86ea0c3ad975..01562e0d4992 100644 --- a/samples/kobject/kobject-example.c +++ b/samples/kobject/kobject-example.c | |||
@@ -40,8 +40,9 @@ static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
40 | return count; | 40 | return count; |
41 | } | 41 | } |
42 | 42 | ||
43 | /* Sysfs attributes cannot be world-writable. */ | ||
43 | static struct kobj_attribute foo_attribute = | 44 | static struct kobj_attribute foo_attribute = |
44 | __ATTR(foo, 0666, foo_show, foo_store); | 45 | __ATTR(foo, 0664, foo_show, foo_store); |
45 | 46 | ||
46 | /* | 47 | /* |
47 | * More complex function where we determine which variable is being accessed by | 48 | * More complex function where we determine which variable is being accessed by |
@@ -73,9 +74,9 @@ static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
73 | } | 74 | } |
74 | 75 | ||
75 | static struct kobj_attribute baz_attribute = | 76 | static struct kobj_attribute baz_attribute = |
76 | __ATTR(baz, 0666, b_show, b_store); | 77 | __ATTR(baz, 0664, b_show, b_store); |
77 | static struct kobj_attribute bar_attribute = | 78 | static struct kobj_attribute bar_attribute = |
78 | __ATTR(bar, 0666, b_show, b_store); | 79 | __ATTR(bar, 0664, b_show, b_store); |
79 | 80 | ||
80 | 81 | ||
81 | /* | 82 | /* |
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index 5dce351f131f..ab5e447ec238 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c | |||
@@ -124,8 +124,9 @@ static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr, | |||
124 | return count; | 124 | return count; |
125 | } | 125 | } |
126 | 126 | ||
127 | /* Sysfs attributes cannot be world-writable. */ | ||
127 | static struct foo_attribute foo_attribute = | 128 | static struct foo_attribute foo_attribute = |
128 | __ATTR(foo, 0666, foo_show, foo_store); | 129 | __ATTR(foo, 0664, foo_show, foo_store); |
129 | 130 | ||
130 | /* | 131 | /* |
131 | * More complex function where we determine which variable is being accessed by | 132 | * More complex function where we determine which variable is being accessed by |
@@ -157,9 +158,9 @@ static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr, | |||
157 | } | 158 | } |
158 | 159 | ||
159 | static struct foo_attribute baz_attribute = | 160 | static struct foo_attribute baz_attribute = |
160 | __ATTR(baz, 0666, b_show, b_store); | 161 | __ATTR(baz, 0664, b_show, b_store); |
161 | static struct foo_attribute bar_attribute = | 162 | static struct foo_attribute bar_attribute = |
162 | __ATTR(bar, 0666, b_show, b_store); | 163 | __ATTR(bar, 0664, b_show, b_store); |
163 | 164 | ||
164 | /* | 165 | /* |
165 | * Create a group of attributes so that we can create and destroy them all | 166 | * Create a group of attributes so that we can create and destroy them all |