lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 21 Jun 2012 12:55:28 +0200
From:	Andrzej Pietrasiewicz <andrzej.p@...sung.com>
To:	linux-usb@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org,
	Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
	Kyungmin Park <kyungmin.park@...sung.com>,
	Felipe Balbi <balbi@...com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Joel Becker <jlbec@...lplan.org>,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
	Marek Szyprowski <m.szyprowski@...sung.com>
Subject: [RFC 1/2] fs: configfs: add check_rmdir operation

The logic behind a subsystem which uses configfs might be that it is not
desired to allow removing the pseudo directories (items or groups) in a
mounted configfs while some criterion is not met, e.g. while some
actions are in progress. This patch adds a check_rmdir operation to
configfs_item_operations and to configfs_group_operations. The operation,
if provided, is called before actual remove takes place and if the result
is nonzero, the remove is not done and the error it returns is reported.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
 fs/configfs/dir.c        |   20 ++++++++++++++++++++
 include/linux/configfs.h |    2 ++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 7e6c52d..de2680f 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1408,12 +1408,32 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
 		dead_item_owner = item->ci_type->ct_owner;
 
 	if (sd->s_type & CONFIGFS_USET_DIR) {
+		if (item->ci_type && item->ci_type->ct_group_ops &&
+		    item->ci_type->ct_group_ops->check_rmdir) {
+		    	ret = item->ci_type->ct_group_ops->check_rmdir(
+				to_config_group(parent_item), item);
+			if (ret) {
+				config_item_put(item);
+				configfs_detach_rollback(dentry);
+				return ret;
+			}
+		}
 		configfs_detach_group(item);
 
 		mutex_lock(&subsys->su_mutex);
 		client_disconnect_notify(parent_item, item);
 		unlink_group(to_config_group(item));
 	} else {
+		if (item->ci_type && item->ci_type->ct_item_ops &&
+		    item->ci_type->ct_item_ops->check_rmdir) {
+		    	ret = item->ci_type->ct_item_ops->check_rmdir(
+				to_config_group(parent_item), item);
+			if (ret) {
+				config_item_put(item);
+				configfs_detach_rollback(dentry);
+				return ret;
+			}
+		}
 		configfs_detach_item(item);
 
 		mutex_lock(&subsys->su_mutex);
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 34025df..f356a55 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -225,6 +225,7 @@ struct configfs_item_operations {
 	void (*release)(struct config_item *);
 	ssize_t	(*show_attribute)(struct config_item *, struct configfs_attribute *,char *);
 	ssize_t	(*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t);
+	int (*check_rmdir)(struct config_group *group, struct config_item *item);
 	int (*allow_link)(struct config_item *src, struct config_item *target);
 	int (*drop_link)(struct config_item *src, struct config_item *target);
 };
@@ -233,6 +234,7 @@ struct configfs_group_operations {
 	struct config_item *(*make_item)(struct config_group *group, const char *name);
 	struct config_group *(*make_group)(struct config_group *group, const char *name);
 	int (*commit_item)(struct config_item *item);
+	int (*check_rmdir)(struct config_group *group, struct config_item *item);
 	void (*disconnect_notify)(struct config_group *group, struct config_item *item);
 	void (*drop_item)(struct config_group *group, struct config_item *item);
 };
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ