From: NeilBrown Date: Mon, 10 Jul 2006 11:44:19 +0000 (-0700) Subject: [PATCH] md: require CAP_SYS_ADMIN for (re-)configuring md devices via sysfs X-Git-Tag: v2.6.18-rc2~217 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67463acb646904d76a8e237cc31eaa87872f30cc;p=linux-2.6 [PATCH] md: require CAP_SYS_ADMIN for (re-)configuring md devices via sysfs The ioctl requires CAP_SYS_ADMIN, so sysfs should too. Note that we don't require CAP_SYS_ADMIN for reading attributes even though the ioctl does. There is no reason to limit the read access, and much of the information is already available via /proc/mdstat Cc: Chris Wright Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/md/md.c b/drivers/md/md.c index c0da5eedc2..a5286beddc 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1926,6 +1926,8 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr, if (!entry->store) return -EIO; + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; return entry->store(rdev, page, length); } @@ -2859,6 +2861,8 @@ md_attr_store(struct kobject *kobj, struct attribute *attr, if (!entry->store) return -EIO; + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; rv = mddev_lock(mddev); if (!rv) { rv = entry->store(mddev, page, length);