[PATCH 25/20] sysfs: Only support removing emtpy sysfs directories.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>

I have looked and I have not found a single legitimate case today where
we remove sysfs directories with anything in them.  The only case I have
found to date was a bug.  It was a problem of ownership.  The files in
the directory where not owned by the directory itself.   Leaving open
the potential for double deletion of the directory contents.

Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxxxxxxxx>
---
 fs/sysfs/dir.c |   24 ++++--------------------
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index b3058f5..6b3e038 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -617,30 +617,14 @@ const struct inode_operations sysfs_dir_inode_operations = {
 	.permission	= sysfs_permission,
 };
 
-static struct sysfs_dirent *sysfs_get_one(struct sysfs_dirent *dir_sd)
-{
-	struct sysfs_dirent *sd = dir_sd;
-	mutex_lock(&sysfs_mutex);
-	while ((sysfs_type(sd) == SYSFS_DIR) && sd->s_dir.children)
-		sd = sd->s_dir.children;
-	if (sd != dir_sd)
-		sysfs_get(sd);
-	else
-		sd = NULL;
-	mutex_unlock(&sysfs_mutex);
-	return sd;
-}
-
 static void remove_dir(struct sysfs_dirent *dir_sd)
 {
-	struct sysfs_dirent *sd;
-
 	pr_debug("sysfs %s: removing dir\n", dir_sd->s_name);
 
-	while ((sd = sysfs_get_one(dir_sd))) {
-		sysfs_remove_one(sd);
-		sysfs_put(sd);
-	}
+	WARN(dir_sd->s_dir.children,
+		KERN_WARNING "sysfs: removing non-empty dir: %s\n",
+		dir_sd->s_name);
+
 	sysfs_remove_one(dir_sd);
 }
 
-- 
1.6.3.1.54.g99dd.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux