4 Extended attribute handling.
6 Copyright (C) 2001 by Andreas Gruenbacher <a.gruenbacher@computer.org>
7 Copyright (C) 2001 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com>
8 Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
11 #include <linux/slab.h>
12 #include <linux/file.h>
13 #include <linux/xattr.h>
14 #include <linux/mount.h>
15 #include <linux/namei.h>
16 #include <linux/security.h>
17 #include <linux/evm.h>
18 #include <linux/syscalls.h>
19 #include <linux/export.h>
20 #include <linux/fsnotify.h>
21 #include <linux/audit.h>
22 #include <linux/vmalloc.h>
23 #include <linux/posix_acl_xattr.h>
25 #include <asm/uaccess.h>
28 * Check permissions for extended attribute access. This is a bit complicated
29 * because different namespaces have very different rules.
32 xattr_permission(struct inode
*inode
, const char *name
, int mask
)
35 * We can never set or remove an extended attribute on a read-only
36 * filesystem or on an immutable / append-only inode.
38 if (mask
& MAY_WRITE
) {
39 if (IS_IMMUTABLE(inode
) || IS_APPEND(inode
))
42 * Updating an xattr will likely cause i_uid and i_gid
43 * to be writen back improperly if their true value is
46 if (HAS_UNMAPPED_ID(inode
))
51 * No restriction for security.* and system.* from the VFS. Decision
52 * on these is left to the underlying filesystem / security module.
54 if (!strncmp(name
, XATTR_SECURITY_PREFIX
, XATTR_SECURITY_PREFIX_LEN
) ||
55 !strncmp(name
, XATTR_SYSTEM_PREFIX
, XATTR_SYSTEM_PREFIX_LEN
))
59 * The trusted.* namespace can only be accessed by privileged users.
61 if (!strncmp(name
, XATTR_TRUSTED_PREFIX
, XATTR_TRUSTED_PREFIX_LEN
)) {
62 if (!capable(CAP_SYS_ADMIN
))
63 return (mask
& MAY_WRITE
) ? -EPERM
: -ENODATA
;
68 * In the user.* namespace, only regular files and directories can have
69 * extended attributes. For sticky directories, only the owner and
70 * privileged users can write attributes.
72 if (!strncmp(name
, XATTR_USER_PREFIX
, XATTR_USER_PREFIX_LEN
)) {
73 if (!S_ISREG(inode
->i_mode
) && !S_ISDIR(inode
->i_mode
))
74 return (mask
& MAY_WRITE
) ? -EPERM
: -ENODATA
;
75 if (S_ISDIR(inode
->i_mode
) && (inode
->i_mode
& S_ISVTX
) &&
76 (mask
& MAY_WRITE
) && !inode_owner_or_capable(inode
))
80 return inode_permission(inode
, mask
);
84 * __vfs_setxattr_noperm - perform setxattr operation without performing
87 * @dentry - object to perform setxattr on
88 * @name - xattr name to set
89 * @value - value to set @name to
90 * @size - size of @value
91 * @flags - flags to pass into filesystem operations
93 * returns the result of the internal setxattr or setsecurity operations.
95 * This function requires the caller to lock the inode's i_mutex before it
96 * is executed. It also assumes that the caller will make the appropriate
99 int __vfs_setxattr_noperm(struct dentry
*dentry
, const char *name
,
100 const void *value
, size_t size
, int flags
)
102 struct inode
*inode
= dentry
->d_inode
;
103 int error
= -EOPNOTSUPP
;
104 int issec
= !strncmp(name
, XATTR_SECURITY_PREFIX
,
105 XATTR_SECURITY_PREFIX_LEN
);
108 inode
->i_flags
&= ~S_NOSEC
;
109 if (inode
->i_op
->setxattr
) {
110 error
= inode
->i_op
->setxattr(dentry
, inode
, name
, value
, size
, flags
);
112 fsnotify_xattr(dentry
);
113 security_inode_post_setxattr(dentry
, name
, value
,
117 const char *suffix
= name
+ XATTR_SECURITY_PREFIX_LEN
;
118 error
= security_inode_setsecurity(inode
, suffix
, value
,
121 fsnotify_xattr(dentry
);
129 vfs_setxattr(struct dentry
*dentry
, const char *name
, const void *value
,
130 size_t size
, int flags
)
132 struct inode
*inode
= dentry
->d_inode
;
135 error
= xattr_permission(inode
, name
, MAY_WRITE
);
140 error
= security_inode_setxattr(dentry
, name
, value
, size
, flags
);
144 error
= __vfs_setxattr_noperm(dentry
, name
, value
, size
, flags
);
150 EXPORT_SYMBOL_GPL(vfs_setxattr
);
153 xattr_getsecurity(struct inode
*inode
, const char *name
, void *value
,
159 if (!value
|| !size
) {
160 len
= security_inode_getsecurity(inode
, name
, &buffer
, false);
164 len
= security_inode_getsecurity(inode
, name
, &buffer
, true);
171 memcpy(value
, buffer
, len
);
173 security_release_secctx(buffer
, len
);
177 EXPORT_SYMBOL_GPL(xattr_getsecurity
);
180 * vfs_getxattr_alloc - allocate memory, if necessary, before calling getxattr
182 * Allocate memory, if not already allocated, or re-allocate correct size,
183 * before retrieving the extended attribute.
185 * Returns the result of alloc, if failed, or the getxattr operation.
188 vfs_getxattr_alloc(struct dentry
*dentry
, const char *name
, char **xattr_value
,
189 size_t xattr_size
, gfp_t flags
)
191 struct inode
*inode
= dentry
->d_inode
;
192 char *value
= *xattr_value
;
195 error
= xattr_permission(inode
, name
, MAY_READ
);
199 if (!inode
->i_op
->getxattr
)
202 error
= inode
->i_op
->getxattr(dentry
, inode
, name
, NULL
, 0);
206 if (!value
|| (error
> xattr_size
)) {
207 value
= krealloc(*xattr_value
, error
+ 1, flags
);
210 memset(value
, 0, error
+ 1);
213 error
= inode
->i_op
->getxattr(dentry
, inode
, name
, value
, error
);
214 *xattr_value
= value
;
219 vfs_getxattr(struct dentry
*dentry
, const char *name
, void *value
, size_t size
)
221 struct inode
*inode
= dentry
->d_inode
;
224 error
= xattr_permission(inode
, name
, MAY_READ
);
228 error
= security_inode_getxattr(dentry
, name
);
232 if (!strncmp(name
, XATTR_SECURITY_PREFIX
,
233 XATTR_SECURITY_PREFIX_LEN
)) {
234 const char *suffix
= name
+ XATTR_SECURITY_PREFIX_LEN
;
235 int ret
= xattr_getsecurity(inode
, suffix
, value
, size
);
237 * Only overwrite the return value if a security module
238 * is actually active.
240 if (ret
== -EOPNOTSUPP
)
245 if (inode
->i_op
->getxattr
)
246 error
= inode
->i_op
->getxattr(dentry
, inode
, name
, value
, size
);
252 EXPORT_SYMBOL_GPL(vfs_getxattr
);
255 vfs_listxattr(struct dentry
*d
, char *list
, size_t size
)
259 error
= security_inode_listxattr(d
);
263 if (d
->d_inode
->i_op
->listxattr
) {
264 error
= d
->d_inode
->i_op
->listxattr(d
, list
, size
);
266 error
= security_inode_listsecurity(d
->d_inode
, list
, size
);
267 if (size
&& error
> size
)
272 EXPORT_SYMBOL_GPL(vfs_listxattr
);
275 vfs_removexattr(struct dentry
*dentry
, const char *name
)
277 struct inode
*inode
= dentry
->d_inode
;
280 if (!inode
->i_op
->removexattr
)
283 error
= xattr_permission(inode
, name
, MAY_WRITE
);
288 error
= security_inode_removexattr(dentry
, name
);
292 error
= inode
->i_op
->removexattr(dentry
, name
);
295 fsnotify_xattr(dentry
);
296 evm_inode_post_removexattr(dentry
, name
);
303 EXPORT_SYMBOL_GPL(vfs_removexattr
);
307 * Extended attribute SET operations
310 setxattr(struct dentry
*d
, const char __user
*name
, const void __user
*value
,
311 size_t size
, int flags
)
315 char kname
[XATTR_NAME_MAX
+ 1];
317 if (flags
& ~(XATTR_CREATE
|XATTR_REPLACE
))
320 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
321 if (error
== 0 || error
== sizeof(kname
))
327 if (size
> XATTR_SIZE_MAX
)
329 kvalue
= kmalloc(size
, GFP_KERNEL
| __GFP_NOWARN
);
331 kvalue
= vmalloc(size
);
335 if (copy_from_user(kvalue
, value
, size
)) {
339 if ((strcmp(kname
, XATTR_NAME_POSIX_ACL_ACCESS
) == 0) ||
340 (strcmp(kname
, XATTR_NAME_POSIX_ACL_DEFAULT
) == 0))
341 posix_acl_fix_xattr_from_user(kvalue
, size
);
344 error
= vfs_setxattr(d
, kname
, kvalue
, size
, flags
);
351 static int path_setxattr(const char __user
*pathname
,
352 const char __user
*name
, const void __user
*value
,
353 size_t size
, int flags
, unsigned int lookup_flags
)
358 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
361 error
= mnt_want_write(path
.mnt
);
363 error
= setxattr(path
.dentry
, name
, value
, size
, flags
);
364 mnt_drop_write(path
.mnt
);
367 if (retry_estale(error
, lookup_flags
)) {
368 lookup_flags
|= LOOKUP_REVAL
;
374 SYSCALL_DEFINE5(setxattr
, const char __user
*, pathname
,
375 const char __user
*, name
, const void __user
*, value
,
376 size_t, size
, int, flags
)
378 return path_setxattr(pathname
, name
, value
, size
, flags
, LOOKUP_FOLLOW
);
381 SYSCALL_DEFINE5(lsetxattr
, const char __user
*, pathname
,
382 const char __user
*, name
, const void __user
*, value
,
383 size_t, size
, int, flags
)
385 return path_setxattr(pathname
, name
, value
, size
, flags
, 0);
388 SYSCALL_DEFINE5(fsetxattr
, int, fd
, const char __user
*, name
,
389 const void __user
*,value
, size_t, size
, int, flags
)
391 struct fd f
= fdget(fd
);
397 error
= mnt_want_write_file(f
.file
);
399 error
= setxattr(f
.file
->f_path
.dentry
, name
, value
, size
, flags
);
400 mnt_drop_write_file(f
.file
);
407 * Extended attribute GET operations
410 getxattr(struct dentry
*d
, const char __user
*name
, void __user
*value
,
415 char kname
[XATTR_NAME_MAX
+ 1];
417 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
418 if (error
== 0 || error
== sizeof(kname
))
424 if (size
> XATTR_SIZE_MAX
)
425 size
= XATTR_SIZE_MAX
;
426 kvalue
= kzalloc(size
, GFP_KERNEL
| __GFP_NOWARN
);
428 kvalue
= vmalloc(size
);
434 error
= vfs_getxattr(d
, kname
, kvalue
, size
);
436 if ((strcmp(kname
, XATTR_NAME_POSIX_ACL_ACCESS
) == 0) ||
437 (strcmp(kname
, XATTR_NAME_POSIX_ACL_DEFAULT
) == 0))
438 posix_acl_fix_xattr_to_user(kvalue
, size
);
439 if (size
&& copy_to_user(value
, kvalue
, error
))
441 } else if (error
== -ERANGE
&& size
>= XATTR_SIZE_MAX
) {
442 /* The file system tried to returned a value bigger
443 than XATTR_SIZE_MAX bytes. Not possible. */
452 static ssize_t
path_getxattr(const char __user
*pathname
,
453 const char __user
*name
, void __user
*value
,
454 size_t size
, unsigned int lookup_flags
)
459 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
462 error
= getxattr(path
.dentry
, name
, value
, size
);
464 if (retry_estale(error
, lookup_flags
)) {
465 lookup_flags
|= LOOKUP_REVAL
;
471 SYSCALL_DEFINE4(getxattr
, const char __user
*, pathname
,
472 const char __user
*, name
, void __user
*, value
, size_t, size
)
474 return path_getxattr(pathname
, name
, value
, size
, LOOKUP_FOLLOW
);
477 SYSCALL_DEFINE4(lgetxattr
, const char __user
*, pathname
,
478 const char __user
*, name
, void __user
*, value
, size_t, size
)
480 return path_getxattr(pathname
, name
, value
, size
, 0);
483 SYSCALL_DEFINE4(fgetxattr
, int, fd
, const char __user
*, name
,
484 void __user
*, value
, size_t, size
)
486 struct fd f
= fdget(fd
);
487 ssize_t error
= -EBADF
;
492 error
= getxattr(f
.file
->f_path
.dentry
, name
, value
, size
);
498 * Extended attribute LIST operations
501 listxattr(struct dentry
*d
, char __user
*list
, size_t size
)
507 if (size
> XATTR_LIST_MAX
)
508 size
= XATTR_LIST_MAX
;
509 klist
= kmalloc(size
, __GFP_NOWARN
| GFP_KERNEL
);
511 klist
= vmalloc(size
);
517 error
= vfs_listxattr(d
, klist
, size
);
519 if (size
&& copy_to_user(list
, klist
, error
))
521 } else if (error
== -ERANGE
&& size
>= XATTR_LIST_MAX
) {
522 /* The file system tried to returned a list bigger
523 than XATTR_LIST_MAX bytes. Not possible. */
532 static ssize_t
path_listxattr(const char __user
*pathname
, char __user
*list
,
533 size_t size
, unsigned int lookup_flags
)
538 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
541 error
= listxattr(path
.dentry
, list
, size
);
543 if (retry_estale(error
, lookup_flags
)) {
544 lookup_flags
|= LOOKUP_REVAL
;
550 SYSCALL_DEFINE3(listxattr
, const char __user
*, pathname
, char __user
*, list
,
553 return path_listxattr(pathname
, list
, size
, LOOKUP_FOLLOW
);
556 SYSCALL_DEFINE3(llistxattr
, const char __user
*, pathname
, char __user
*, list
,
559 return path_listxattr(pathname
, list
, size
, 0);
562 SYSCALL_DEFINE3(flistxattr
, int, fd
, char __user
*, list
, size_t, size
)
564 struct fd f
= fdget(fd
);
565 ssize_t error
= -EBADF
;
570 error
= listxattr(f
.file
->f_path
.dentry
, list
, size
);
576 * Extended attribute REMOVE operations
579 removexattr(struct dentry
*d
, const char __user
*name
)
582 char kname
[XATTR_NAME_MAX
+ 1];
584 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
585 if (error
== 0 || error
== sizeof(kname
))
590 return vfs_removexattr(d
, kname
);
593 static int path_removexattr(const char __user
*pathname
,
594 const char __user
*name
, unsigned int lookup_flags
)
599 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
602 error
= mnt_want_write(path
.mnt
);
604 error
= removexattr(path
.dentry
, name
);
605 mnt_drop_write(path
.mnt
);
608 if (retry_estale(error
, lookup_flags
)) {
609 lookup_flags
|= LOOKUP_REVAL
;
615 SYSCALL_DEFINE2(removexattr
, const char __user
*, pathname
,
616 const char __user
*, name
)
618 return path_removexattr(pathname
, name
, LOOKUP_FOLLOW
);
621 SYSCALL_DEFINE2(lremovexattr
, const char __user
*, pathname
,
622 const char __user
*, name
)
624 return path_removexattr(pathname
, name
, 0);
627 SYSCALL_DEFINE2(fremovexattr
, int, fd
, const char __user
*, name
)
629 struct fd f
= fdget(fd
);
635 error
= mnt_want_write_file(f
.file
);
637 error
= removexattr(f
.file
->f_path
.dentry
, name
);
638 mnt_drop_write_file(f
.file
);
646 strcmp_prefix(const char *a
, const char *a_prefix
)
648 while (*a_prefix
&& *a
== *a_prefix
) {
652 return *a_prefix
? NULL
: a
;
656 * In order to implement different sets of xattr operations for each xattr
657 * prefix with the generic xattr API, a filesystem should create a
658 * null-terminated array of struct xattr_handler (one for each prefix) and
659 * hang a pointer to it off of the s_xattr field of the superblock.
661 * The generic_fooxattr() functions will use this list to dispatch xattr
662 * operations to the correct xattr_handler.
664 #define for_each_xattr_handler(handlers, handler) \
666 for ((handler) = *(handlers)++; \
668 (handler) = *(handlers)++)
671 * Find the xattr_handler with the matching prefix.
673 static const struct xattr_handler
*
674 xattr_resolve_name(const struct xattr_handler
**handlers
, const char **name
)
676 const struct xattr_handler
*handler
;
678 for_each_xattr_handler(handlers
, handler
) {
681 n
= strcmp_prefix(*name
, xattr_prefix(handler
));
683 if (!handler
->prefix
^ !*n
) {
686 return ERR_PTR(-EINVAL
);
692 return ERR_PTR(-EOPNOTSUPP
);
696 * Find the handler for the prefix and dispatch its get() operation.
699 generic_getxattr(struct dentry
*dentry
, struct inode
*inode
,
700 const char *name
, void *buffer
, size_t size
)
702 const struct xattr_handler
*handler
;
704 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
706 return PTR_ERR(handler
);
707 return handler
->get(handler
, dentry
, inode
,
712 * Combine the results of the list() operation from every xattr_handler in the
716 generic_listxattr(struct dentry
*dentry
, char *buffer
, size_t buffer_size
)
718 const struct xattr_handler
*handler
, **handlers
= dentry
->d_sb
->s_xattr
;
719 unsigned int size
= 0;
722 for_each_xattr_handler(handlers
, handler
) {
723 if (!handler
->name
||
724 (handler
->list
&& !handler
->list(dentry
)))
726 size
+= strlen(handler
->name
) + 1;
732 for_each_xattr_handler(handlers
, handler
) {
733 if (!handler
->name
||
734 (handler
->list
&& !handler
->list(dentry
)))
736 len
= strlen(handler
->name
);
737 if (len
+ 1 > buffer_size
)
739 memcpy(buf
, handler
->name
, len
+ 1);
741 buffer_size
-= len
+ 1;
749 * Find the handler for the prefix and dispatch its set() operation.
752 generic_setxattr(struct dentry
*dentry
, struct inode
*inode
, const char *name
,
753 const void *value
, size_t size
, int flags
)
755 const struct xattr_handler
*handler
;
758 value
= ""; /* empty EA, do not remove */
759 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
761 return PTR_ERR(handler
);
762 return handler
->set(handler
, dentry
, inode
, name
, value
, size
, flags
);
766 * Find the handler for the prefix and dispatch its set() operation to remove
767 * any associated extended attribute.
770 generic_removexattr(struct dentry
*dentry
, const char *name
)
772 const struct xattr_handler
*handler
;
774 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
776 return PTR_ERR(handler
);
777 return handler
->set(handler
, dentry
, d_inode(dentry
), name
, NULL
,
781 EXPORT_SYMBOL(generic_getxattr
);
782 EXPORT_SYMBOL(generic_listxattr
);
783 EXPORT_SYMBOL(generic_setxattr
);
784 EXPORT_SYMBOL(generic_removexattr
);
787 * xattr_full_name - Compute full attribute name from suffix
789 * @handler: handler of the xattr_handler operation
790 * @name: name passed to the xattr_handler operation
792 * The get and set xattr handler operations are called with the remainder of
793 * the attribute name after skipping the handler's prefix: for example, "foo"
794 * is passed to the get operation of a handler with prefix "user." to get
795 * attribute "user.foo". The full name is still "there" in the name though.
797 * Note: the list xattr handler operation when called from the vfs is passed a
798 * NULL name; some file systems use this operation internally, with varying
801 const char *xattr_full_name(const struct xattr_handler
*handler
,
804 size_t prefix_len
= strlen(xattr_prefix(handler
));
806 return name
- prefix_len
;
808 EXPORT_SYMBOL(xattr_full_name
);
811 * Allocate new xattr and copy in the value; but leave the name to callers.
813 struct simple_xattr
*simple_xattr_alloc(const void *value
, size_t size
)
815 struct simple_xattr
*new_xattr
;
819 len
= sizeof(*new_xattr
) + size
;
820 if (len
< sizeof(*new_xattr
))
823 new_xattr
= kmalloc(len
, GFP_KERNEL
);
827 new_xattr
->size
= size
;
828 memcpy(new_xattr
->value
, value
, size
);
833 * xattr GET operation for in-memory/pseudo filesystems
835 int simple_xattr_get(struct simple_xattrs
*xattrs
, const char *name
,
836 void *buffer
, size_t size
)
838 struct simple_xattr
*xattr
;
841 spin_lock(&xattrs
->lock
);
842 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
843 if (strcmp(name
, xattr
->name
))
848 if (size
< xattr
->size
)
851 memcpy(buffer
, xattr
->value
, xattr
->size
);
855 spin_unlock(&xattrs
->lock
);
860 * simple_xattr_set - xattr SET operation for in-memory/pseudo filesystems
861 * @xattrs: target simple_xattr list
862 * @name: name of the extended attribute
863 * @value: value of the xattr. If %NULL, will remove the attribute.
864 * @size: size of the new xattr
865 * @flags: %XATTR_{CREATE|REPLACE}
867 * %XATTR_CREATE is set, the xattr shouldn't exist already; otherwise fails
868 * with -EEXIST. If %XATTR_REPLACE is set, the xattr should exist;
869 * otherwise, fails with -ENODATA.
871 * Returns 0 on success, -errno on failure.
873 int simple_xattr_set(struct simple_xattrs
*xattrs
, const char *name
,
874 const void *value
, size_t size
, int flags
)
876 struct simple_xattr
*xattr
;
877 struct simple_xattr
*new_xattr
= NULL
;
880 /* value == NULL means remove */
882 new_xattr
= simple_xattr_alloc(value
, size
);
886 new_xattr
->name
= kstrdup(name
, GFP_KERNEL
);
887 if (!new_xattr
->name
) {
893 spin_lock(&xattrs
->lock
);
894 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
895 if (!strcmp(name
, xattr
->name
)) {
896 if (flags
& XATTR_CREATE
) {
899 } else if (new_xattr
) {
900 list_replace(&xattr
->list
, &new_xattr
->list
);
902 list_del(&xattr
->list
);
907 if (flags
& XATTR_REPLACE
) {
911 list_add(&new_xattr
->list
, &xattrs
->head
);
915 spin_unlock(&xattrs
->lock
);
924 static bool xattr_is_trusted(const char *name
)
926 return !strncmp(name
, XATTR_TRUSTED_PREFIX
, XATTR_TRUSTED_PREFIX_LEN
);
929 static int xattr_list_one(char **buffer
, ssize_t
*remaining_size
,
932 size_t len
= strlen(name
) + 1;
934 if (*remaining_size
< len
)
936 memcpy(*buffer
, name
, len
);
939 *remaining_size
-= len
;
944 * xattr LIST operation for in-memory/pseudo filesystems
946 ssize_t
simple_xattr_list(struct inode
*inode
, struct simple_xattrs
*xattrs
,
947 char *buffer
, size_t size
)
949 bool trusted
= capable(CAP_SYS_ADMIN
);
950 struct simple_xattr
*xattr
;
951 ssize_t remaining_size
= size
;
954 #ifdef CONFIG_FS_POSIX_ACL
956 err
= xattr_list_one(&buffer
, &remaining_size
,
957 XATTR_NAME_POSIX_ACL_ACCESS
);
961 if (inode
->i_default_acl
) {
962 err
= xattr_list_one(&buffer
, &remaining_size
,
963 XATTR_NAME_POSIX_ACL_DEFAULT
);
969 spin_lock(&xattrs
->lock
);
970 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
971 /* skip "trusted." attributes for unprivileged callers */
972 if (!trusted
&& xattr_is_trusted(xattr
->name
))
975 err
= xattr_list_one(&buffer
, &remaining_size
, xattr
->name
);
979 spin_unlock(&xattrs
->lock
);
981 return err
? err
: size
- remaining_size
;
985 * Adds an extended attribute to the list
987 void simple_xattr_list_add(struct simple_xattrs
*xattrs
,
988 struct simple_xattr
*new_xattr
)
990 spin_lock(&xattrs
->lock
);
991 list_add(&new_xattr
->list
, &xattrs
->head
);
992 spin_unlock(&xattrs
->lock
);