OpenVZ Forum - RDF feed
type: channel
items: [PATCH 04/15] sysfs: Implement __sysfs_get_dentry
items: [PATCH 05/15] sysfs: Rename Support multiple superblocks
items: [PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod
items: Re: [PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod

[PATCH 04/15] sysfs: Implement __sysfs_get_dentry
type: item
description: This function is similar but much simpler to sysfs_get_dentry returns a sysfs dentry if one curently exists. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Acked-by: Tejun Heo <tj@kernel.org> --- fs/sysfs/dir.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 69c40ed..df9934a 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -764,6 +764,45 @@ void sysfs_remove_dir(struct kobject * kobj) __sysfs_remove_dir(sd); } +/** + * __sysfs_get_dentry - get dentry for the given sysfs_dirent + * @sb: superblock of the dentry to return + * @sd: sysfs_dirent of interest + * + * Get dentry for @sd. Only return a dentry if one currently + * exists. + * + * LOCKING: + * Kernel thread context (may sleep) + * + * RETURNS: + * Pointer to found dentry on success, NULL on failure. + */ +static struct dentry *__sysfs_get_dentry(struct super_block *sb, + struct sysfs_dirent *sd) +{ + struct inode *inode; + struct dentry *dentry = NULL; + + inode = ilookup5_nowait(sysfs_sb, sd->s_ino, sysfs_ilookup_test, sd); + if (inode && !(inode->i_state & I_NEW)) { + struct dentry *alias; + spin_lock(&dcache_lock); + list_for_each_entry(alias, &inode->i_dentry, d_alias) { + if (!IS_ROOT(alias) && d_unhashed(alias)) + continue; + if (alias->d_sb != sb) + continue; + dentry = alias; + dget_locked(dentry); + break; + } + spin_unlock(&dcache_lock); + } + iput(inode); + return dentry; +} + int sysfs_rename_dir(struct kobject * kobj, const char *new_name) { struct sysfs_dirent *sd = kobj->sd; -- 1.5.3.rc6.17.g1911 _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: ebiederm
date: 2008-07-04T01:09:04-00:00

[PATCH 05/15] sysfs: Rename Support multiple superblocks
type: item
description: This patch modifies the sysfs_rename_dir and sysfs_move_dir routines to support multiple sysfs dentry tries rooted in different sysfs superblocks. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Acked-by: Tejun Heo <tj@kernel.org> --- fs/sysfs/dir.c | 193 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 136 insertions(+), 57 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index df9934a..b2d92ea 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -803,43 +803,113 @@ static struct dentry *__sysfs_get_dentry(struct super_block *sb, return dentry; } +struct sysfs_rename_struct { + struct list_head list; + struct dentry *old_dentry; + struct dentry *new_dentry; + struct dentry *old_parent; + struct dentry *new_parent; +}; + +static void post_rename(struct list_head *head) +{ + struct sysfs_rename_struct *srs; + while (!list_empty(head)) { + srs = list_entry(head->next, struct sysfs_rename_struct, list); + dput(srs->old_dentry); + dput(srs->new_dentry); + dput(srs->old_parent); + dput(srs->new_parent); + list_del(&srs->list); + kfree(srs); + } +} + +static int prep_rename(struct list_head *head, + struct sysfs_dirent *sd, struct sysfs_dirent *new_parent_sd, + const char *name) +{ + struct sysfs_rename_struct *srs; + struct super_block *sb; + struct dentry *dentry; + int error; + + list_for_each_entry(sb, &sysfs_fs_type.fs_supers, s_instances) { + dentry = sysfs_get_dentry(sb, sd); + if (dentry == ERR_PTR(-EXDEV)) + continue; + if (IS_ERR(dentry)) { + error = PTR_ERR(dentry); + goto err_out; + } + + srs = kzalloc(sizeof(*srs), GFP_KERNEL); + if (!srs) { + error = -ENOMEM; + dput(dentry); + goto err_out; + } + + INIT_LIST_HEAD(&srs->list); + list_add(head, &srs->list); + srs->old_dentry = dentry; + srs->old_parent = dget(dentry->d_parent); + + dentry = sysfs_get_dentry(sb, new_parent_sd); + if (IS_ERR(dentry)) { + error = PT…
creator: ebiederm
date: 2008-07-04T01:10:05-00:00

[PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod
type: item
description: Currently sysfs_chmod calls sys_setattr which in turn calls inode_change_ok which checks to see if it is ok for the current user space process to change tha attributes. Since sysfs_chmod_file has only kernel mode clients denying them permission if user space is the problem is completely inappropriate. Therefore factor out sysfs_sd_setattr which does not call inode_change_ok and modify sysfs_chmod_file to call it. In addition setting victim_sd->s_mode explicitly in sysfs_chmod_file is redundant so remove that as well. Thanks to Tejun Heo <htejun@gmail.com>, and Daniel Lezcano <dlezcano@fr.ibm.com> for working on this and spotting this case. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> --- fs/sysfs/file.c | 5 +---- fs/sysfs/inode.c | 23 ++++++++++++++++------- fs/sysfs/sysfs.h | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index cb5dd3f..1304b3a 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -600,13 +600,10 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; newattrs.ia_ctime = current_fs_time(inode->i_sb); - rc = sysfs_setattr(victim, &newattrs); + rc = sysfs_sd_setattr(victim_sd, inode, &newattrs); if (rc == 0) { fsnotify_change(victim, newattrs.ia_valid); - mutex_lock(&sysfs_mutex); - victim_sd->s_mode = newattrs.ia_mode; - mutex_unlock(&sysfs_mutex); } mutex_unlock(&inode->i_mutex); diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index eb53c63..80f8fd4 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c @@ -42,10 +42,9 @@ int __init sysfs_inode_init(void) return bdi_init(&sysfs_backing_dev_info); } -int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) +int sysfs_sd_setattr(struct sysfs_dirent *sd, struct inode *inode, + struct iattr * iattr) { - struct inode * inode = dentry->d_inode; - struct sysfs_dirent * sd = dentry->d_fsdata; str…
creator: ebiederm
date: 2008-07-04T01:11:40-00:00

Re: [PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod
type: item
description: Eric W. Biederman wrote: > Currently sysfs_chmod calls sys_setattr which in turn calls > inode_change_ok which checks to see if it is ok for the current user > space process to change tha attributes. Since sysfs_chmod_file has > only kernel mode clients denying them permission if user space is the > problem is completely inappropriate. > > Therefore factor out sysfs_sd_setattr which does not call > inode_change_ok and modify sysfs_chmod_file to call it. > > In addition setting victim_sd->s_mode explicitly in sysfs_chmod_file > is redundant so remove that as well. > > Thanks to Tejun Heo <htejun@gmail.com>, and > Daniel Lezcano <dlezcano@fr.ibm.com> for working on this > and spotting this case. > > Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Tejun Heo <tj@kernel.org> -- tejun _______________________________________________ Containers mailing list Containers@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/containers
creator: Tejun Heo
date: 2008-07-04T06:40:19-00:00