Commit 6e3ff3c2 authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: llite: set security xattr using __vfs_setxattr

Currently ll_initxattrs() initializes the security xattrs in
a very non-standard using get_xattr_types() to get the struct
handler that lustre created to then call indirectly the function
to set the xattr. The available __vfs_setxattr() function does
the same thing and also handles the case of when size is zero
the xattr should be set to empty EA.
Signed-off-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/27240Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: default avatarBob Glossman <bob.glossman@intel.com>
Reviewed-by: default avatarSebastien Buisson <sbuisson@ddn.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a49c8634
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
* lustre/llite/xattr_security.c * lustre/llite/xattr_security.c
* Handler for storing security labels as extended attributes. * Handler for storing security labels as extended attributes.
*/ */
#include <linux/types.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/selinux.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include "llite_internal.h" #include "llite_internal.h"
...@@ -48,19 +51,23 @@ static int ...@@ -48,19 +51,23 @@ static int
ll_initxattrs(struct inode *inode, const struct xattr *xattr_array, ll_initxattrs(struct inode *inode, const struct xattr *xattr_array,
void *fs_info) void *fs_info)
{ {
const struct xattr_handler *handler;
struct dentry *dentry = fs_info; struct dentry *dentry = fs_info;
const struct xattr *xattr; const struct xattr *xattr;
int err = 0; int err = 0;
handler = get_xattr_type(XATTR_SECURITY_PREFIX);
if (!handler)
return -ENXIO;
for (xattr = xattr_array; xattr->name; xattr++) { for (xattr = xattr_array; xattr->name; xattr++) {
err = handler->set(handler, dentry, inode, xattr->name, char *full_name;
xattr->value, xattr->value_len,
XATTR_CREATE); full_name = kasprintf(GFP_KERNEL, "%s%s",
XATTR_SECURITY_PREFIX, xattr->name);
if (!full_name) {
err = -ENOMEM;
break;
}
err = __vfs_setxattr(dentry, inode, full_name, xattr->value,
xattr->value_len, XATTR_CREATE);
kfree(full_name);
if (err < 0) if (err < 0)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment