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] [day] [month] [year] [list]
Date:	Tue, 28 Apr 2015 11:52:49 -0500
From:	Felipe Balbi <balbi@...com>
To:	Krzysztof Opasiak <k.opasiak@...sung.com>
CC:	<balbi@...com>, <gregkh@...uxfoundation.org>, <jlbec@...lplan.org>,
	<andrzej.p@...sung.com>, <m.szyprowski@...sung.com>,
	<linux-api@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux-usb@...r.kernel.org>
Subject: Re: [PATCH v3 1/4] fs: configfs: Add unlocked version of
 configfs_depend_item()

Hi,

On Thu, Apr 09, 2015 at 06:18:07PM +0200, Krzysztof Opasiak wrote:
> Sometimes it might be desirable to prohibit removing a directory
> in configfs. One example is USB gadget (mass_storage function):
> when gadget is already bound, if lun directory is removed,
> the gadget must be thrown away, too. A better solution would be
> to fail with e.g. -EBUSY.
> 
> Currently configfs has configfs_depend/undepend_item() methods
> but they cannot be used in configfs callbacks. This commit
> adds unlocked version of this methods which can be used
> only in configfs callbacks.
> 
> Signed-off-by: Krzysztof Opasiak <k.opasiak@...sung.com>

Joel, any comments to this patch ?

> ---
>  fs/configfs/dir.c        |   29 +++++++++++++++++++++++++++++
>  include/linux/configfs.h |    9 +++++++++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index cf0db00..7875a5e 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1152,6 +1152,35 @@ void configfs_undepend_item(struct configfs_subsystem *subsys,
>  }
>  EXPORT_SYMBOL(configfs_undepend_item);
>  
> +int configfs_depend_item_unlocked(struct config_item *target)
> +{
> +	struct configfs_dirent *sd;
> +	int ret = -ENOENT;
> +
> +	spin_lock(&configfs_dirent_lock);
> +	BUG_ON(!target->ci_dentry);
> +
> +	sd = target->ci_dentry->d_fsdata;
> +	if ((sd->s_type & CONFIGFS_DIR) &&
> +	    ((sd->s_type & CONFIGFS_USET_DROPPING) ||
> +	     (sd->s_type & CONFIGFS_USET_CREATING)))
> +		goto out_unlock_dirent_lock;
> +
> +	sd->s_dependent_count += 1;
> +	ret = 0;
> +
> +out_unlock_dirent_lock:
> +	spin_unlock(&configfs_dirent_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL(configfs_depend_item_unlocked);
> +
> +void configfs_undepend_item_unlocked(struct config_item *target)
> +{
> +	configfs_undepend_item(NULL, target);
> +}
> +EXPORT_SYMBOL(configfs_undepend_item_unlocked);
> +
>  static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  {
>  	int ret = 0;
> diff --git a/include/linux/configfs.h b/include/linux/configfs.h
> index 34025df..e9dbf01 100644
> --- a/include/linux/configfs.h
> +++ b/include/linux/configfs.h
> @@ -257,4 +257,13 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
>  int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);
>  void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target);
>  
> +/*
> + * These functions can sleep and can alloc with GFP_KERNEL
> + * NOTE: These should be called only underneath configfs callbacks.
> + * WARNING: These cannot be called on newly created item
> + *        (in make_group()/make_item callback)
> + */
> +int configfs_depend_item_unlocked(struct config_item *target);
> +void configfs_undepend_item_unlocked(struct config_item *target);
> +
>  #endif /* _CONFIGFS_H_ */
> -- 
> 1.7.9.5
> 

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ