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
, 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
);
139 mutex_lock(&inode
->i_mutex
);
140 error
= security_inode_setxattr(dentry
, name
, value
, size
, flags
);
144 error
= __vfs_setxattr_noperm(dentry
, name
, value
, size
, flags
);
147 mutex_unlock(&inode
->i_mutex
);
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
, 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
, name
, value
, error
);
214 *xattr_value
= value
;
217 EXPORT_SYMBOL(vfs_getxattr_alloc
);
219 /* Compare an extended attribute value with the given value */
220 int vfs_xattr_cmp(struct dentry
*dentry
, const char *xattr_name
,
221 const char *value
, size_t size
, gfp_t flags
)
223 char *xattr_value
= NULL
;
226 rc
= vfs_getxattr_alloc(dentry
, xattr_name
, &xattr_value
, 0, flags
);
230 if ((rc
!= size
) || (memcmp(xattr_value
, value
, rc
) != 0))
239 vfs_getxattr(struct dentry
*dentry
, const char *name
, void *value
, size_t size
)
241 struct inode
*inode
= dentry
->d_inode
;
244 error
= xattr_permission(inode
, name
, MAY_READ
);
248 error
= security_inode_getxattr(dentry
, name
);
252 if (!strncmp(name
, XATTR_SECURITY_PREFIX
,
253 XATTR_SECURITY_PREFIX_LEN
)) {
254 const char *suffix
= name
+ XATTR_SECURITY_PREFIX_LEN
;
255 int ret
= xattr_getsecurity(inode
, suffix
, value
, size
);
257 * Only overwrite the return value if a security module
258 * is actually active.
260 if (ret
== -EOPNOTSUPP
)
265 if (inode
->i_op
->getxattr
)
266 error
= inode
->i_op
->getxattr(dentry
, name
, value
, size
);
272 EXPORT_SYMBOL_GPL(vfs_getxattr
);
275 vfs_listxattr(struct dentry
*d
, char *list
, size_t size
)
279 error
= security_inode_listxattr(d
);
283 if (d
->d_inode
->i_op
->listxattr
) {
284 error
= d
->d_inode
->i_op
->listxattr(d
, list
, size
);
286 error
= security_inode_listsecurity(d
->d_inode
, list
, size
);
287 if (size
&& error
> size
)
292 EXPORT_SYMBOL_GPL(vfs_listxattr
);
295 vfs_removexattr(struct dentry
*dentry
, const char *name
)
297 struct inode
*inode
= dentry
->d_inode
;
300 if (!inode
->i_op
->removexattr
)
303 error
= xattr_permission(inode
, name
, MAY_WRITE
);
307 mutex_lock(&inode
->i_mutex
);
308 error
= security_inode_removexattr(dentry
, name
);
312 error
= inode
->i_op
->removexattr(dentry
, name
);
315 fsnotify_xattr(dentry
);
316 evm_inode_post_removexattr(dentry
, name
);
320 mutex_unlock(&inode
->i_mutex
);
323 EXPORT_SYMBOL_GPL(vfs_removexattr
);
327 * Extended attribute SET operations
330 setxattr(struct dentry
*d
, const char __user
*name
, const void __user
*value
,
331 size_t size
, int flags
)
335 void *vvalue
= NULL
; /* If non-NULL, we used vmalloc() */
336 char kname
[XATTR_NAME_MAX
+ 1];
338 if (flags
& ~(XATTR_CREATE
|XATTR_REPLACE
))
341 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
342 if (error
== 0 || error
== sizeof(kname
))
348 if (size
> XATTR_SIZE_MAX
)
350 kvalue
= kmalloc(size
, GFP_KERNEL
| __GFP_NOWARN
);
352 vvalue
= vmalloc(size
);
357 if (copy_from_user(kvalue
, value
, size
)) {
361 if ((strcmp(kname
, XATTR_NAME_POSIX_ACL_ACCESS
) == 0) ||
362 (strcmp(kname
, XATTR_NAME_POSIX_ACL_DEFAULT
) == 0))
363 posix_acl_fix_xattr_from_user(kvalue
, size
);
366 error
= vfs_setxattr(d
, kname
, kvalue
, size
, flags
);
375 static int path_setxattr(const char __user
*pathname
,
376 const char __user
*name
, const void __user
*value
,
377 size_t size
, int flags
, unsigned int lookup_flags
)
382 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
385 error
= mnt_want_write(path
.mnt
);
387 error
= setxattr(path
.dentry
, name
, value
, size
, flags
);
388 mnt_drop_write(path
.mnt
);
391 if (retry_estale(error
, lookup_flags
)) {
392 lookup_flags
|= LOOKUP_REVAL
;
398 SYSCALL_DEFINE5(setxattr
, const char __user
*, pathname
,
399 const char __user
*, name
, const void __user
*, value
,
400 size_t, size
, int, flags
)
402 return path_setxattr(pathname
, name
, value
, size
, flags
, LOOKUP_FOLLOW
);
405 SYSCALL_DEFINE5(lsetxattr
, const char __user
*, pathname
,
406 const char __user
*, name
, const void __user
*, value
,
407 size_t, size
, int, flags
)
409 return path_setxattr(pathname
, name
, value
, size
, flags
, 0);
412 SYSCALL_DEFINE5(fsetxattr
, int, fd
, const char __user
*, name
,
413 const void __user
*,value
, size_t, size
, int, flags
)
415 struct fd f
= fdget(fd
);
421 error
= mnt_want_write_file(f
.file
);
423 error
= setxattr(f
.file
->f_path
.dentry
, name
, value
, size
, flags
);
424 mnt_drop_write_file(f
.file
);
431 * Extended attribute GET operations
434 getxattr(struct dentry
*d
, const char __user
*name
, void __user
*value
,
440 char kname
[XATTR_NAME_MAX
+ 1];
442 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
443 if (error
== 0 || error
== sizeof(kname
))
449 if (size
> XATTR_SIZE_MAX
)
450 size
= XATTR_SIZE_MAX
;
451 kvalue
= kzalloc(size
, GFP_KERNEL
| __GFP_NOWARN
);
453 vvalue
= vmalloc(size
);
460 error
= vfs_getxattr(d
, kname
, kvalue
, size
);
462 if ((strcmp(kname
, XATTR_NAME_POSIX_ACL_ACCESS
) == 0) ||
463 (strcmp(kname
, XATTR_NAME_POSIX_ACL_DEFAULT
) == 0))
464 posix_acl_fix_xattr_to_user(kvalue
, size
);
465 if (size
&& copy_to_user(value
, kvalue
, error
))
467 } else if (error
== -ERANGE
&& size
>= XATTR_SIZE_MAX
) {
468 /* The file system tried to returned a value bigger
469 than XATTR_SIZE_MAX bytes. Not possible. */
479 static ssize_t
path_getxattr(const char __user
*pathname
,
480 const char __user
*name
, void __user
*value
,
481 size_t size
, unsigned int lookup_flags
)
486 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
489 error
= getxattr(path
.dentry
, name
, value
, size
);
491 if (retry_estale(error
, lookup_flags
)) {
492 lookup_flags
|= LOOKUP_REVAL
;
498 SYSCALL_DEFINE4(getxattr
, const char __user
*, pathname
,
499 const char __user
*, name
, void __user
*, value
, size_t, size
)
501 return path_getxattr(pathname
, name
, value
, size
, LOOKUP_FOLLOW
);
504 SYSCALL_DEFINE4(lgetxattr
, const char __user
*, pathname
,
505 const char __user
*, name
, void __user
*, value
, size_t, size
)
507 return path_getxattr(pathname
, name
, value
, size
, 0);
510 SYSCALL_DEFINE4(fgetxattr
, int, fd
, const char __user
*, name
,
511 void __user
*, value
, size_t, size
)
513 struct fd f
= fdget(fd
);
514 ssize_t error
= -EBADF
;
519 error
= getxattr(f
.file
->f_path
.dentry
, name
, value
, size
);
525 * Extended attribute LIST operations
528 listxattr(struct dentry
*d
, char __user
*list
, size_t size
)
532 char *vlist
= NULL
; /* If non-NULL, we used vmalloc() */
535 if (size
> XATTR_LIST_MAX
)
536 size
= XATTR_LIST_MAX
;
537 klist
= kmalloc(size
, __GFP_NOWARN
| GFP_KERNEL
);
539 vlist
= vmalloc(size
);
546 error
= vfs_listxattr(d
, klist
, size
);
548 if (size
&& copy_to_user(list
, klist
, error
))
550 } else if (error
== -ERANGE
&& size
>= XATTR_LIST_MAX
) {
551 /* The file system tried to returned a list bigger
552 than XATTR_LIST_MAX bytes. Not possible. */
562 static ssize_t
path_listxattr(const char __user
*pathname
, char __user
*list
,
563 size_t size
, unsigned int lookup_flags
)
568 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
571 error
= listxattr(path
.dentry
, list
, size
);
573 if (retry_estale(error
, lookup_flags
)) {
574 lookup_flags
|= LOOKUP_REVAL
;
580 SYSCALL_DEFINE3(listxattr
, const char __user
*, pathname
, char __user
*, list
,
583 return path_listxattr(pathname
, list
, size
, LOOKUP_FOLLOW
);
586 SYSCALL_DEFINE3(llistxattr
, const char __user
*, pathname
, char __user
*, list
,
589 return path_listxattr(pathname
, list
, size
, 0);
592 SYSCALL_DEFINE3(flistxattr
, int, fd
, char __user
*, list
, size_t, size
)
594 struct fd f
= fdget(fd
);
595 ssize_t error
= -EBADF
;
600 error
= listxattr(f
.file
->f_path
.dentry
, list
, size
);
606 * Extended attribute REMOVE operations
609 removexattr(struct dentry
*d
, const char __user
*name
)
612 char kname
[XATTR_NAME_MAX
+ 1];
614 error
= strncpy_from_user(kname
, name
, sizeof(kname
));
615 if (error
== 0 || error
== sizeof(kname
))
620 return vfs_removexattr(d
, kname
);
623 static int path_removexattr(const char __user
*pathname
,
624 const char __user
*name
, unsigned int lookup_flags
)
629 error
= user_path_at(AT_FDCWD
, pathname
, lookup_flags
, &path
);
632 error
= mnt_want_write(path
.mnt
);
634 error
= removexattr(path
.dentry
, name
);
635 mnt_drop_write(path
.mnt
);
638 if (retry_estale(error
, lookup_flags
)) {
639 lookup_flags
|= LOOKUP_REVAL
;
645 SYSCALL_DEFINE2(removexattr
, const char __user
*, pathname
,
646 const char __user
*, name
)
648 return path_removexattr(pathname
, name
, LOOKUP_FOLLOW
);
651 SYSCALL_DEFINE2(lremovexattr
, const char __user
*, pathname
,
652 const char __user
*, name
)
654 return path_removexattr(pathname
, name
, 0);
657 SYSCALL_DEFINE2(fremovexattr
, int, fd
, const char __user
*, name
)
659 struct fd f
= fdget(fd
);
665 error
= mnt_want_write_file(f
.file
);
667 error
= removexattr(f
.file
->f_path
.dentry
, name
);
668 mnt_drop_write_file(f
.file
);
676 strcmp_prefix(const char *a
, const char *a_prefix
)
678 while (*a_prefix
&& *a
== *a_prefix
) {
682 return *a_prefix
? NULL
: a
;
686 * In order to implement different sets of xattr operations for each xattr
687 * prefix with the generic xattr API, a filesystem should create a
688 * null-terminated array of struct xattr_handler (one for each prefix) and
689 * hang a pointer to it off of the s_xattr field of the superblock.
691 * The generic_fooxattr() functions will use this list to dispatch xattr
692 * operations to the correct xattr_handler.
694 #define for_each_xattr_handler(handlers, handler) \
695 for ((handler) = *(handlers)++; \
697 (handler) = *(handlers)++)
700 * Find the xattr_handler with the matching prefix.
702 static const struct xattr_handler
*
703 xattr_resolve_name(const struct xattr_handler
**handlers
, const char **name
)
705 const struct xattr_handler
*handler
;
710 for_each_xattr_handler(handlers
, handler
) {
711 const char *n
= strcmp_prefix(*name
, handler
->prefix
);
721 * Find the handler for the prefix and dispatch its get() operation.
724 generic_getxattr(struct dentry
*dentry
, const char *name
, void *buffer
, size_t size
)
726 const struct xattr_handler
*handler
;
728 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
731 return handler
->get(handler
, dentry
, name
, buffer
, size
);
735 * Combine the results of the list() operation from every xattr_handler in the
739 generic_listxattr(struct dentry
*dentry
, char *buffer
, size_t buffer_size
)
741 const struct xattr_handler
*handler
, **handlers
= dentry
->d_sb
->s_xattr
;
742 unsigned int size
= 0;
745 for_each_xattr_handler(handlers
, handler
) {
746 size
+= handler
->list(handler
, dentry
, NULL
, 0,
752 for_each_xattr_handler(handlers
, handler
) {
753 size
= handler
->list(handler
, dentry
, buf
, buffer_size
,
755 if (size
> buffer_size
)
766 * Find the handler for the prefix and dispatch its set() operation.
769 generic_setxattr(struct dentry
*dentry
, const char *name
, const void *value
, size_t size
, int flags
)
771 const struct xattr_handler
*handler
;
774 value
= ""; /* empty EA, do not remove */
775 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
778 return handler
->set(handler
, dentry
, name
, value
, size
, flags
);
782 * Find the handler for the prefix and dispatch its set() operation to remove
783 * any associated extended attribute.
786 generic_removexattr(struct dentry
*dentry
, const char *name
)
788 const struct xattr_handler
*handler
;
790 handler
= xattr_resolve_name(dentry
->d_sb
->s_xattr
, &name
);
793 return handler
->set(handler
, dentry
, name
, NULL
, 0, XATTR_REPLACE
);
796 EXPORT_SYMBOL(generic_getxattr
);
797 EXPORT_SYMBOL(generic_listxattr
);
798 EXPORT_SYMBOL(generic_setxattr
);
799 EXPORT_SYMBOL(generic_removexattr
);
802 * xattr_full_name - Compute full attribute name from suffix
804 * @handler: handler of the xattr_handler operation
805 * @name: name passed to the xattr_handler operation
807 * The get and set xattr handler operations are called with the remainder of
808 * the attribute name after skipping the handler's prefix: for example, "foo"
809 * is passed to the get operation of a handler with prefix "user." to get
810 * attribute "user.foo". The full name is still "there" in the name though.
812 * Note: the list xattr handler operation when called from the vfs is passed a
813 * NULL name; some file systems use this operation internally, with varying
816 const char *xattr_full_name(const struct xattr_handler
*handler
,
819 size_t prefix_len
= strlen(handler
->prefix
);
821 return name
- prefix_len
;
823 EXPORT_SYMBOL(xattr_full_name
);
826 * Allocate new xattr and copy in the value; but leave the name to callers.
828 struct simple_xattr
*simple_xattr_alloc(const void *value
, size_t size
)
830 struct simple_xattr
*new_xattr
;
834 len
= sizeof(*new_xattr
) + size
;
835 if (len
< sizeof(*new_xattr
))
838 new_xattr
= kmalloc(len
, GFP_KERNEL
);
842 new_xattr
->size
= size
;
843 memcpy(new_xattr
->value
, value
, size
);
848 * xattr GET operation for in-memory/pseudo filesystems
850 int simple_xattr_get(struct simple_xattrs
*xattrs
, const char *name
,
851 void *buffer
, size_t size
)
853 struct simple_xattr
*xattr
;
856 spin_lock(&xattrs
->lock
);
857 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
858 if (strcmp(name
, xattr
->name
))
863 if (size
< xattr
->size
)
866 memcpy(buffer
, xattr
->value
, xattr
->size
);
870 spin_unlock(&xattrs
->lock
);
874 static int __simple_xattr_set(struct simple_xattrs
*xattrs
, const char *name
,
875 const void *value
, size_t size
, int flags
)
877 struct simple_xattr
*xattr
;
878 struct simple_xattr
*new_xattr
= NULL
;
881 /* value == NULL means remove */
883 new_xattr
= simple_xattr_alloc(value
, size
);
887 new_xattr
->name
= kstrdup(name
, GFP_KERNEL
);
888 if (!new_xattr
->name
) {
894 spin_lock(&xattrs
->lock
);
895 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
896 if (!strcmp(name
, xattr
->name
)) {
897 if (flags
& XATTR_CREATE
) {
900 } else if (new_xattr
) {
901 list_replace(&xattr
->list
, &new_xattr
->list
);
903 list_del(&xattr
->list
);
908 if (flags
& XATTR_REPLACE
) {
912 list_add(&new_xattr
->list
, &xattrs
->head
);
916 spin_unlock(&xattrs
->lock
);
926 * simple_xattr_set - xattr SET operation for in-memory/pseudo filesystems
927 * @xattrs: target simple_xattr list
928 * @name: name of the new extended attribute
929 * @value: value of the new xattr. If %NULL, will remove the attribute
930 * @size: size of the new xattr
931 * @flags: %XATTR_{CREATE|REPLACE}
933 * %XATTR_CREATE is set, the xattr shouldn't exist already; otherwise fails
934 * with -EEXIST. If %XATTR_REPLACE is set, the xattr should exist;
935 * otherwise, fails with -ENODATA.
937 * Returns 0 on success, -errno on failure.
939 int simple_xattr_set(struct simple_xattrs
*xattrs
, const char *name
,
940 const void *value
, size_t size
, int flags
)
943 value
= ""; /* empty EA, do not remove */
944 return __simple_xattr_set(xattrs
, name
, value
, size
, flags
);
948 * xattr REMOVE operation for in-memory/pseudo filesystems
950 int simple_xattr_remove(struct simple_xattrs
*xattrs
, const char *name
)
952 return __simple_xattr_set(xattrs
, name
, NULL
, 0, XATTR_REPLACE
);
955 static bool xattr_is_trusted(const char *name
)
957 return !strncmp(name
, XATTR_TRUSTED_PREFIX
, XATTR_TRUSTED_PREFIX_LEN
);
961 * xattr LIST operation for in-memory/pseudo filesystems
963 ssize_t
simple_xattr_list(struct simple_xattrs
*xattrs
, char *buffer
,
966 bool trusted
= capable(CAP_SYS_ADMIN
);
967 struct simple_xattr
*xattr
;
970 spin_lock(&xattrs
->lock
);
971 list_for_each_entry(xattr
, &xattrs
->head
, list
) {
974 /* skip "trusted." attributes for unprivileged callers */
975 if (!trusted
&& xattr_is_trusted(xattr
->name
))
978 len
= strlen(xattr
->name
) + 1;
985 memcpy(buffer
, xattr
->name
, len
);
989 spin_unlock(&xattrs
->lock
);
995 * Adds an extended attribute to the list
997 void simple_xattr_list_add(struct simple_xattrs
*xattrs
,
998 struct simple_xattr
*new_xattr
)
1000 spin_lock(&xattrs
->lock
);
1001 list_add(&new_xattr
->list
, &xattrs
->head
);
1002 spin_unlock(&xattrs
->lock
);