diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-23 17:40:02 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-04 10:34:45 -0500 |
commit | 2322392b020badfe49730f1529b9c1a15248c387 (patch) | |
tree | da17c0d183045351ae25f8173f2c0cfd7c7b8a55 /fs/kernfs/dir.c | |
parent | 9a8049affd55a2c857a89faece27b878416fbf91 (diff) |
kernfs: implement "trusted.*" xattr support
kernfs inherited "security.*" xattr support from sysfs. This patch
extends xattr support to "trusted.*" using simple_xattr_*(). As
trusted xattrs are restricted to CAP_SYS_ADMIN, simple_xattr_*() which
uses kernel memory for storage shouldn't be problematic.
Note that the existing "security.*" support doesn't implement
get/remove/list and the this patch only implements those ops for
"trusted.*". We probably want to extend those ops to include support
for "security.*".
This patch will allow using kernfs from cgroup which requires
"trusted.*" xattr support.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: David P. Quigley <dpquigl@tycho.nsa.gov>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r-- | fs/kernfs/dir.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index f51e0625e666..a441e3be8052 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -243,9 +243,12 @@ void kernfs_put(struct sysfs_dirent *sd) | |||
243 | kernfs_put(sd->s_symlink.target_sd); | 243 | kernfs_put(sd->s_symlink.target_sd); |
244 | if (sysfs_type(sd) & SYSFS_COPY_NAME) | 244 | if (sysfs_type(sd) & SYSFS_COPY_NAME) |
245 | kfree(sd->s_name); | 245 | kfree(sd->s_name); |
246 | if (sd->s_iattr && sd->s_iattr->ia_secdata) | 246 | if (sd->s_iattr) { |
247 | security_release_secctx(sd->s_iattr->ia_secdata, | 247 | if (sd->s_iattr->ia_secdata) |
248 | sd->s_iattr->ia_secdata_len); | 248 | security_release_secctx(sd->s_iattr->ia_secdata, |
249 | sd->s_iattr->ia_secdata_len); | ||
250 | simple_xattrs_free(&sd->s_iattr->xattrs); | ||
251 | } | ||
249 | kfree(sd->s_iattr); | 252 | kfree(sd->s_iattr); |
250 | ida_simple_remove(&root->ino_ida, sd->s_ino); | 253 | ida_simple_remove(&root->ino_ida, sd->s_ino); |
251 | kmem_cache_free(sysfs_dir_cachep, sd); | 254 | kmem_cache_free(sysfs_dir_cachep, sd); |
@@ -718,6 +721,9 @@ const struct inode_operations sysfs_dir_inode_operations = { | |||
718 | .setattr = sysfs_setattr, | 721 | .setattr = sysfs_setattr, |
719 | .getattr = sysfs_getattr, | 722 | .getattr = sysfs_getattr, |
720 | .setxattr = sysfs_setxattr, | 723 | .setxattr = sysfs_setxattr, |
724 | .removexattr = sysfs_removexattr, | ||
725 | .getxattr = sysfs_getxattr, | ||
726 | .listxattr = sysfs_listxattr, | ||
721 | }; | 727 | }; |
722 | 728 | ||
723 | static struct sysfs_dirent *sysfs_leftmost_descendant(struct sysfs_dirent *pos) | 729 | static struct sysfs_dirent *sysfs_leftmost_descendant(struct sysfs_dirent *pos) |