|
@@ -2561,94 +2561,47 @@ static int shmem_initxattrs(struct inode *inode,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static const struct xattr_handler *shmem_xattr_handlers[] = {
|
|
|
|
-#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
|
|
- &posix_acl_access_xattr_handler,
|
|
|
|
- &posix_acl_default_xattr_handler,
|
|
|
|
-#endif
|
|
|
|
- NULL
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-static int shmem_xattr_validate(const char *name)
|
|
|
|
-{
|
|
|
|
- struct { const char *prefix; size_t len; } arr[] = {
|
|
|
|
- { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
|
|
|
|
- { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
|
|
|
|
- };
|
|
|
|
- int i;
|
|
|
|
-
|
|
|
|
- for (i = 0; i < ARRAY_SIZE(arr); i++) {
|
|
|
|
- size_t preflen = arr[i].len;
|
|
|
|
- if (strncmp(name, arr[i].prefix, preflen) == 0) {
|
|
|
|
- if (!name[preflen])
|
|
|
|
- return -EINVAL;
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return -EOPNOTSUPP;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static ssize_t shmem_getxattr(struct dentry *dentry, const char *name,
|
|
|
|
- void *buffer, size_t size)
|
|
|
|
|
|
+static int shmem_xattr_handler_get(const struct xattr_handler *handler,
|
|
|
|
+ struct dentry *dentry, const char *name,
|
|
|
|
+ void *buffer, size_t size)
|
|
{
|
|
{
|
|
struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
|
|
struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
|
|
- int err;
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * If this is a request for a synthetic attribute in the system.*
|
|
|
|
- * namespace use the generic infrastructure to resolve a handler
|
|
|
|
- * for it via sb->s_xattr.
|
|
|
|
- */
|
|
|
|
- if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
|
|
|
|
- return generic_getxattr(dentry, name, buffer, size);
|
|
|
|
-
|
|
|
|
- err = shmem_xattr_validate(name);
|
|
|
|
- if (err)
|
|
|
|
- return err;
|
|
|
|
|
|
|
|
|
|
+ name = xattr_full_name(handler, name);
|
|
return simple_xattr_get(&info->xattrs, name, buffer, size);
|
|
return simple_xattr_get(&info->xattrs, name, buffer, size);
|
|
}
|
|
}
|
|
|
|
|
|
-static int shmem_setxattr(struct dentry *dentry, const char *name,
|
|
|
|
- const void *value, size_t size, int flags)
|
|
|
|
|
|
+static int shmem_xattr_handler_set(const struct xattr_handler *handler,
|
|
|
|
+ struct dentry *dentry, const char *name,
|
|
|
|
+ const void *value, size_t size, int flags)
|
|
{
|
|
{
|
|
struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
|
|
struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
|
|
- int err;
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * If this is a request for a synthetic attribute in the system.*
|
|
|
|
- * namespace use the generic infrastructure to resolve a handler
|
|
|
|
- * for it via sb->s_xattr.
|
|
|
|
- */
|
|
|
|
- if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
|
|
|
|
- return generic_setxattr(dentry, name, value, size, flags);
|
|
|
|
-
|
|
|
|
- err = shmem_xattr_validate(name);
|
|
|
|
- if (err)
|
|
|
|
- return err;
|
|
|
|
|
|
|
|
|
|
+ name = xattr_full_name(handler, name);
|
|
return simple_xattr_set(&info->xattrs, name, value, size, flags);
|
|
return simple_xattr_set(&info->xattrs, name, value, size, flags);
|
|
}
|
|
}
|
|
|
|
|
|
-static int shmem_removexattr(struct dentry *dentry, const char *name)
|
|
|
|
-{
|
|
|
|
- struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
|
|
|
|
- int err;
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * If this is a request for a synthetic attribute in the system.*
|
|
|
|
- * namespace use the generic infrastructure to resolve a handler
|
|
|
|
- * for it via sb->s_xattr.
|
|
|
|
- */
|
|
|
|
- if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
|
|
|
|
- return generic_removexattr(dentry, name);
|
|
|
|
|
|
+static const struct xattr_handler shmem_security_xattr_handler = {
|
|
|
|
+ .prefix = XATTR_SECURITY_PREFIX,
|
|
|
|
+ .get = shmem_xattr_handler_get,
|
|
|
|
+ .set = shmem_xattr_handler_set,
|
|
|
|
+};
|
|
|
|
|
|
- err = shmem_xattr_validate(name);
|
|
|
|
- if (err)
|
|
|
|
- return err;
|
|
|
|
|
|
+static const struct xattr_handler shmem_trusted_xattr_handler = {
|
|
|
|
+ .prefix = XATTR_TRUSTED_PREFIX,
|
|
|
|
+ .get = shmem_xattr_handler_get,
|
|
|
|
+ .set = shmem_xattr_handler_set,
|
|
|
|
+};
|
|
|
|
|
|
- return simple_xattr_remove(&info->xattrs, name);
|
|
|
|
-}
|
|
|
|
|
|
+static const struct xattr_handler *shmem_xattr_handlers[] = {
|
|
|
|
+#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
|
|
+ &posix_acl_access_xattr_handler,
|
|
|
|
+ &posix_acl_default_xattr_handler,
|
|
|
|
+#endif
|
|
|
|
+ &shmem_security_xattr_handler,
|
|
|
|
+ &shmem_trusted_xattr_handler,
|
|
|
|
+ NULL
|
|
|
|
+};
|
|
|
|
|
|
static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
|
static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
|
{
|
|
{
|
|
@@ -2661,10 +2614,10 @@ static const struct inode_operations shmem_short_symlink_operations = {
|
|
.readlink = generic_readlink,
|
|
.readlink = generic_readlink,
|
|
.follow_link = simple_follow_link,
|
|
.follow_link = simple_follow_link,
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
- .setxattr = shmem_setxattr,
|
|
|
|
- .getxattr = shmem_getxattr,
|
|
|
|
|
|
+ .setxattr = generic_setxattr,
|
|
|
|
+ .getxattr = generic_getxattr,
|
|
.listxattr = shmem_listxattr,
|
|
.listxattr = shmem_listxattr,
|
|
- .removexattr = shmem_removexattr,
|
|
|
|
|
|
+ .removexattr = generic_removexattr,
|
|
#endif
|
|
#endif
|
|
};
|
|
};
|
|
|
|
|
|
@@ -2673,10 +2626,10 @@ static const struct inode_operations shmem_symlink_inode_operations = {
|
|
.follow_link = shmem_follow_link,
|
|
.follow_link = shmem_follow_link,
|
|
.put_link = shmem_put_link,
|
|
.put_link = shmem_put_link,
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
- .setxattr = shmem_setxattr,
|
|
|
|
- .getxattr = shmem_getxattr,
|
|
|
|
|
|
+ .setxattr = generic_setxattr,
|
|
|
|
+ .getxattr = generic_getxattr,
|
|
.listxattr = shmem_listxattr,
|
|
.listxattr = shmem_listxattr,
|
|
- .removexattr = shmem_removexattr,
|
|
|
|
|
|
+ .removexattr = generic_removexattr,
|
|
#endif
|
|
#endif
|
|
};
|
|
};
|
|
|
|
|
|
@@ -3148,10 +3101,10 @@ static const struct inode_operations shmem_inode_operations = {
|
|
.getattr = shmem_getattr,
|
|
.getattr = shmem_getattr,
|
|
.setattr = shmem_setattr,
|
|
.setattr = shmem_setattr,
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
- .setxattr = shmem_setxattr,
|
|
|
|
- .getxattr = shmem_getxattr,
|
|
|
|
|
|
+ .setxattr = generic_setxattr,
|
|
|
|
+ .getxattr = generic_getxattr,
|
|
.listxattr = shmem_listxattr,
|
|
.listxattr = shmem_listxattr,
|
|
- .removexattr = shmem_removexattr,
|
|
|
|
|
|
+ .removexattr = generic_removexattr,
|
|
.set_acl = simple_set_acl,
|
|
.set_acl = simple_set_acl,
|
|
#endif
|
|
#endif
|
|
};
|
|
};
|
|
@@ -3170,10 +3123,10 @@ static const struct inode_operations shmem_dir_inode_operations = {
|
|
.tmpfile = shmem_tmpfile,
|
|
.tmpfile = shmem_tmpfile,
|
|
#endif
|
|
#endif
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
- .setxattr = shmem_setxattr,
|
|
|
|
- .getxattr = shmem_getxattr,
|
|
|
|
|
|
+ .setxattr = generic_setxattr,
|
|
|
|
+ .getxattr = generic_getxattr,
|
|
.listxattr = shmem_listxattr,
|
|
.listxattr = shmem_listxattr,
|
|
- .removexattr = shmem_removexattr,
|
|
|
|
|
|
+ .removexattr = generic_removexattr,
|
|
#endif
|
|
#endif
|
|
#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
.setattr = shmem_setattr,
|
|
.setattr = shmem_setattr,
|
|
@@ -3183,10 +3136,10 @@ static const struct inode_operations shmem_dir_inode_operations = {
|
|
|
|
|
|
static const struct inode_operations shmem_special_inode_operations = {
|
|
static const struct inode_operations shmem_special_inode_operations = {
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
#ifdef CONFIG_TMPFS_XATTR
|
|
- .setxattr = shmem_setxattr,
|
|
|
|
- .getxattr = shmem_getxattr,
|
|
|
|
|
|
+ .setxattr = generic_setxattr,
|
|
|
|
+ .getxattr = generic_getxattr,
|
|
.listxattr = shmem_listxattr,
|
|
.listxattr = shmem_listxattr,
|
|
- .removexattr = shmem_removexattr,
|
|
|
|
|
|
+ .removexattr = generic_removexattr,
|
|
#endif
|
|
#endif
|
|
#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
#ifdef CONFIG_TMPFS_POSIX_ACL
|
|
.setattr = shmem_setattr,
|
|
.setattr = shmem_setattr,
|