diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-14 05:03:50 +0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-05-14 05:23:57 +0400 |
commit | de5109898a8a0cb001abcb6916bef4efa32bf39b (patch) | |
tree | 458943406396cf7904b23ecd0bff7169c29b69a8 /samples/kobject/kset-example.c | |
parent | f92201c34885cf0da5403c6959bc9bcd9a648963 (diff) | |
download | linux-de5109898a8a0cb001abcb6916bef4efa32bf39b.tar.xz |
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>
Diffstat (limited to 'samples/kobject/kset-example.c')
-rw-r--r-- | samples/kobject/kset-example.c | 7 |
1 files changed, 4 insertions, 3 deletions
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, return count; } +/* Sysfs attributes cannot be world-writable. */ static struct foo_attribute foo_attribute = - __ATTR(foo, 0666, foo_show, foo_store); + __ATTR(foo, 0664, foo_show, foo_store); /* * 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, } static struct foo_attribute baz_attribute = - __ATTR(baz, 0666, b_show, b_store); + __ATTR(baz, 0664, b_show, b_store); static struct foo_attribute bar_attribute = - __ATTR(bar, 0666, b_show, b_store); + __ATTR(bar, 0664, b_show, b_store); /* * Create a group of attributes so that we can create and destroy them all |