All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	Greg Kroah-Hartman <greg@kroah.com>
Subject: [PATCH 8/9] samples/kobject/: avoid world-writable sysfs files.
Date: Tue, 22 Apr 2014 13:03:31 +0930	[thread overview]
Message-ID: <1398137612-9714-9-git-send-email-rusty@rustcorp.com.au> (raw)
In-Reply-To: <1398137612-9714-1-git-send-email-rusty@rustcorp.com.au>

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>
---
 samples/kobject/kobject-example.c | 7 ++++---
 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,
 	return count;
 }
 
+/* Sysfs attributes cannot be world-writable. */
 static struct kobj_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
@@ -73,9 +74,9 @@ static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr,
 }
 
 static struct kobj_attribute baz_attribute =
-	__ATTR(baz, 0666, b_show, b_store);
+	__ATTR(baz, 0664, b_show, b_store);
 static struct kobj_attribute bar_attribute =
-	__ATTR(bar, 0666, b_show, b_store);
+	__ATTR(bar, 0664, b_show, b_store);
 
 
 /*
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
-- 
1.8.3.2


  parent reply	other threads:[~2014-04-22  4:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22  3:33 [PATCH 0/9] Avoid world-writable sysfs files Rusty Russell
2014-04-22  3:33 ` [PATCH 1/9] drivers/mtd/devices/docg3.c: avoid " Rusty Russell
2014-04-22  3:33 ` [PATCH 2/9] drivers/video/fbdev/sm501fb.c: " Rusty Russell
2014-04-22  3:33 ` [PATCH 3/9] drivers/hid/hid-lg4ff.c: " Rusty Russell
2014-04-22 16:30   ` simon
2014-04-23  5:34     ` Rusty Russell
2014-04-23 15:06       ` simon
2014-04-24  3:25         ` Rusty Russell
     [not found]           ` <gz6xrj.n4iwpm.2st9zt-qmf@smtp.devoid-pointer.net>
2014-04-24  7:14             ` Rusty Russell
2014-04-22  3:33 ` [PATCH 4/9] drivers/scsi/pm8001/pm8001_ctl.c: " Rusty Russell
2014-04-22  3:33 ` [PATCH 5/9] drivers/regulator/virtual: " Rusty Russell
2014-04-22  3:33 ` [PATCH 6/9] drivers/staging/speakup/: " Rusty Russell
2014-04-22 16:37   ` Greg Kroah-Hartman
2014-04-24  4:27     ` Rusty Russell
2014-04-24 19:29       ` Greg Kroah-Hartman
2014-04-22  3:33 ` [PATCH 7/9] drivers/hid/hid-picolcd_fb: " Rusty Russell
2014-05-02 19:43   ` Bruno Prémont
2014-05-05  1:57     ` Rusty Russell
2014-05-05  9:02       ` Jiri Kosina
2014-04-22  3:33 ` Rusty Russell [this message]
2014-04-22 16:38   ` [PATCH 8/9] samples/kobject/: " Greg Kroah-Hartman
2014-04-22  3:33 ` [PATCH 9/9] sysfs: disallow world-writable files Rusty Russell
2015-04-29 12:24   ` Gobinda Charan Maji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398137612-9714-9-git-send-email-rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.