1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2002,2003 by Andreas Gruenbacher <a.gruenbacher@computer.org>
5 * Fixes from William Schumacher incorporated on 15 March 2001.
6 * (Reported by Charles Bertsch, <CBertsch@microtest.com>).
10 * This file contains generic functions for manipulating
11 * POSIX 1003.1e draft standard 17 ACLs.
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
16 #include <linux/atomic.h>
18 #include <linux/sched.h>
19 #include <linux/cred.h>
20 #include <linux/posix_acl.h>
21 #include <linux/posix_acl_xattr.h>
22 #include <linux/xattr.h>
23 #include <linux/export.h>
24 #include <linux/user_namespace.h>
25 #include <linux/namei.h>
26 #include <linux/mnt_idmapping.h>
28 static struct posix_acl **acl_by_type(struct inode *inode, int type)
33 case ACL_TYPE_DEFAULT:
34 return &inode->i_default_acl;
40 struct posix_acl *get_cached_acl(struct inode *inode, int type)
42 struct posix_acl **p = acl_by_type(inode, type);
43 struct posix_acl *acl;
47 acl = rcu_dereference(*p);
48 if (!acl || is_uncached_acl(acl) ||
49 refcount_inc_not_zero(&acl->a_refcount))
57 EXPORT_SYMBOL(get_cached_acl);
59 struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type)
61 struct posix_acl *acl = rcu_dereference(*acl_by_type(inode, type));
63 if (acl == ACL_DONT_CACHE) {
64 struct posix_acl *ret;
66 ret = inode->i_op->get_acl(inode, type, LOOKUP_RCU);
73 EXPORT_SYMBOL(get_cached_acl_rcu);
75 void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl)
77 struct posix_acl **p = acl_by_type(inode, type);
78 struct posix_acl *old;
80 old = xchg(p, posix_acl_dup(acl));
81 if (!is_uncached_acl(old))
82 posix_acl_release(old);
84 EXPORT_SYMBOL(set_cached_acl);
86 static void __forget_cached_acl(struct posix_acl **p)
88 struct posix_acl *old;
90 old = xchg(p, ACL_NOT_CACHED);
91 if (!is_uncached_acl(old))
92 posix_acl_release(old);
95 void forget_cached_acl(struct inode *inode, int type)
97 __forget_cached_acl(acl_by_type(inode, type));
99 EXPORT_SYMBOL(forget_cached_acl);
101 void forget_all_cached_acls(struct inode *inode)
103 __forget_cached_acl(&inode->i_acl);
104 __forget_cached_acl(&inode->i_default_acl);
106 EXPORT_SYMBOL(forget_all_cached_acls);
108 struct posix_acl *get_acl(struct inode *inode, int type)
111 struct posix_acl **p;
112 struct posix_acl *acl;
115 * The sentinel is used to detect when another operation like
116 * set_cached_acl() or forget_cached_acl() races with get_acl().
117 * It is guaranteed that is_uncached_acl(sentinel) is true.
120 acl = get_cached_acl(inode, type);
121 if (!is_uncached_acl(acl))
124 if (!IS_POSIXACL(inode))
127 sentinel = uncached_acl_sentinel(current);
128 p = acl_by_type(inode, type);
131 * If the ACL isn't being read yet, set our sentinel. Otherwise, the
132 * current value of the ACL will not be ACL_NOT_CACHED and so our own
133 * sentinel will not be set; another task will update the cache. We
134 * could wait for that other task to complete its job, but it's easier
135 * to just call ->get_acl to fetch the ACL ourself. (This is going to
136 * be an unlikely race.)
138 cmpxchg(p, ACL_NOT_CACHED, sentinel);
141 * Normally, the ACL returned by ->get_acl will be cached.
142 * A filesystem can prevent that by calling
143 * forget_cached_acl(inode, type) in ->get_acl.
145 * If the filesystem doesn't have a get_acl() function at all, we'll
146 * just create the negative cache entry.
148 if (!inode->i_op->get_acl) {
149 set_cached_acl(inode, type, NULL);
152 acl = inode->i_op->get_acl(inode, type, false);
156 * Remove our sentinel so that we don't block future attempts
159 cmpxchg(p, sentinel, ACL_NOT_CACHED);
164 * Cache the result, but only if our sentinel is still in place.
167 if (unlikely(cmpxchg(p, sentinel, acl) != sentinel))
168 posix_acl_release(acl);
171 EXPORT_SYMBOL(get_acl);
174 * Init a fresh posix_acl
177 posix_acl_init(struct posix_acl *acl, int count)
179 refcount_set(&acl->a_refcount, 1);
180 acl->a_count = count;
182 EXPORT_SYMBOL(posix_acl_init);
185 * Allocate a new ACL with the specified number of entries.
188 posix_acl_alloc(int count, gfp_t flags)
190 const size_t size = sizeof(struct posix_acl) +
191 count * sizeof(struct posix_acl_entry);
192 struct posix_acl *acl = kmalloc(size, flags);
194 posix_acl_init(acl, count);
197 EXPORT_SYMBOL(posix_acl_alloc);
203 posix_acl_clone(const struct posix_acl *acl, gfp_t flags)
205 struct posix_acl *clone = NULL;
208 int size = sizeof(struct posix_acl) + acl->a_count *
209 sizeof(struct posix_acl_entry);
210 clone = kmemdup(acl, size, flags);
212 refcount_set(&clone->a_refcount, 1);
216 EXPORT_SYMBOL_GPL(posix_acl_clone);
219 * Check if an acl is valid. Returns 0 if it is, or -E... otherwise.
222 posix_acl_valid(struct user_namespace *user_ns, const struct posix_acl *acl)
224 const struct posix_acl_entry *pa, *pe;
225 int state = ACL_USER_OBJ;
228 FOREACH_ACL_ENTRY(pa, acl, pe) {
229 if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
233 if (state == ACL_USER_OBJ) {
240 if (state != ACL_USER)
242 if (!kuid_has_mapping(user_ns, pa->e_uid))
248 if (state == ACL_USER) {
255 if (state != ACL_GROUP)
257 if (!kgid_has_mapping(user_ns, pa->e_gid))
263 if (state != ACL_GROUP)
269 if (state == ACL_OTHER ||
270 (state == ACL_GROUP && !needs_mask)) {
284 EXPORT_SYMBOL(posix_acl_valid);
287 * Returns 0 if the acl can be exactly represented in the traditional
288 * file mode permission bits, or else 1. Returns -E... on error.
291 posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p)
293 const struct posix_acl_entry *pa, *pe;
298 * A null ACL can always be presented as mode bits.
303 FOREACH_ACL_ENTRY(pa, acl, pe) {
306 mode |= (pa->e_perm & S_IRWXO) << 6;
309 mode |= (pa->e_perm & S_IRWXO) << 3;
312 mode |= pa->e_perm & S_IRWXO;
315 mode = (mode & ~S_IRWXG) |
316 ((pa->e_perm & S_IRWXO) << 3);
328 *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
331 EXPORT_SYMBOL(posix_acl_equiv_mode);
334 * Create an ACL representing the file mode permission bits of an inode.
337 posix_acl_from_mode(umode_t mode, gfp_t flags)
339 struct posix_acl *acl = posix_acl_alloc(3, flags);
341 return ERR_PTR(-ENOMEM);
343 acl->a_entries[0].e_tag = ACL_USER_OBJ;
344 acl->a_entries[0].e_perm = (mode & S_IRWXU) >> 6;
346 acl->a_entries[1].e_tag = ACL_GROUP_OBJ;
347 acl->a_entries[1].e_perm = (mode & S_IRWXG) >> 3;
349 acl->a_entries[2].e_tag = ACL_OTHER;
350 acl->a_entries[2].e_perm = (mode & S_IRWXO);
353 EXPORT_SYMBOL(posix_acl_from_mode);
356 * Return 0 if current is granted want access to the inode
357 * by the acl. Returns -E... otherwise.
360 posix_acl_permission(struct user_namespace *mnt_userns, struct inode *inode,
361 const struct posix_acl *acl, int want)
363 const struct posix_acl_entry *pa, *pe, *mask_obj;
368 want &= MAY_READ | MAY_WRITE | MAY_EXEC;
370 FOREACH_ACL_ENTRY(pa, acl, pe) {
373 /* (May have been checked already) */
374 vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
375 if (vfsuid_eq_kuid(vfsuid, current_fsuid()))
379 vfsuid = make_vfsuid(mnt_userns, &init_user_ns,
381 if (vfsuid_eq_kuid(vfsuid, current_fsuid()))
385 vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
386 if (vfsgid_in_group_p(vfsgid)) {
388 if ((pa->e_perm & want) == want)
393 vfsgid = make_vfsgid(mnt_userns, &init_user_ns,
395 if (vfsgid_in_group_p(vfsgid)) {
397 if ((pa->e_perm & want) == want)
415 for (mask_obj = pa+1; mask_obj != pe; mask_obj++) {
416 if (mask_obj->e_tag == ACL_MASK) {
417 if ((pa->e_perm & mask_obj->e_perm & want) == want)
424 if ((pa->e_perm & want) == want)
430 * Modify acl when creating a new inode. The caller must ensure the acl is
431 * only referenced once.
433 * mode_p initially must contain the mode parameter to the open() / creat()
434 * system calls. All permissions that are not granted by the acl are removed.
435 * The permissions in the acl are changed to reflect the mode_p parameter.
437 static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
439 struct posix_acl_entry *pa, *pe;
440 struct posix_acl_entry *group_obj = NULL, *mask_obj = NULL;
441 umode_t mode = *mode_p;
444 /* assert(atomic_read(acl->a_refcount) == 1); */
446 FOREACH_ACL_ENTRY(pa, acl, pe) {
449 pa->e_perm &= (mode >> 6) | ~S_IRWXO;
450 mode &= (pa->e_perm << 6) | ~S_IRWXU;
463 pa->e_perm &= mode | ~S_IRWXO;
464 mode &= pa->e_perm | ~S_IRWXO;
478 mask_obj->e_perm &= (mode >> 3) | ~S_IRWXO;
479 mode &= (mask_obj->e_perm << 3) | ~S_IRWXG;
483 group_obj->e_perm &= (mode >> 3) | ~S_IRWXO;
484 mode &= (group_obj->e_perm << 3) | ~S_IRWXG;
487 *mode_p = (*mode_p & ~S_IRWXUGO) | mode;
492 * Modify the ACL for the chmod syscall.
494 static int __posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
496 struct posix_acl_entry *group_obj = NULL, *mask_obj = NULL;
497 struct posix_acl_entry *pa, *pe;
499 /* assert(atomic_read(acl->a_refcount) == 1); */
501 FOREACH_ACL_ENTRY(pa, acl, pe) {
504 pa->e_perm = (mode & S_IRWXU) >> 6;
520 pa->e_perm = (mode & S_IRWXO);
529 mask_obj->e_perm = (mode & S_IRWXG) >> 3;
533 group_obj->e_perm = (mode & S_IRWXG) >> 3;
540 __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
542 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
545 err = posix_acl_create_masq(clone, mode_p);
547 posix_acl_release(clone);
551 posix_acl_release(*acl);
555 EXPORT_SYMBOL(__posix_acl_create);
558 __posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
560 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
563 err = __posix_acl_chmod_masq(clone, mode);
565 posix_acl_release(clone);
569 posix_acl_release(*acl);
573 EXPORT_SYMBOL(__posix_acl_chmod);
576 * posix_acl_chmod - chmod a posix acl
578 * @mnt_userns: user namespace of the mount @inode was found from
579 * @inode: inode to check permissions on
580 * @mode: the new mode of @inode
582 * If the inode has been found through an idmapped mount the user namespace of
583 * the vfsmount must be passed through @mnt_userns. This function will then
584 * take care to map the inode according to @mnt_userns before checking
585 * permissions. On non-idmapped mounts or if permission checking is to be
586 * performed on the raw inode simply passs init_user_ns.
589 posix_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode,
592 struct posix_acl *acl;
595 if (!IS_POSIXACL(inode))
597 if (!inode->i_op->set_acl)
600 acl = get_acl(inode, ACL_TYPE_ACCESS);
601 if (IS_ERR_OR_NULL(acl)) {
602 if (acl == ERR_PTR(-EOPNOTSUPP))
607 ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
610 ret = inode->i_op->set_acl(mnt_userns, inode, acl, ACL_TYPE_ACCESS);
611 posix_acl_release(acl);
614 EXPORT_SYMBOL(posix_acl_chmod);
617 posix_acl_create(struct inode *dir, umode_t *mode,
618 struct posix_acl **default_acl, struct posix_acl **acl)
621 struct posix_acl *clone;
627 if (S_ISLNK(*mode) || !IS_POSIXACL(dir))
630 p = get_acl(dir, ACL_TYPE_DEFAULT);
631 if (!p || p == ERR_PTR(-EOPNOTSUPP)) {
632 *mode &= ~current_umask();
639 clone = posix_acl_clone(p, GFP_NOFS);
643 ret = posix_acl_create_masq(clone, mode);
645 goto err_release_clone;
648 posix_acl_release(clone);
653 posix_acl_release(p);
660 posix_acl_release(clone);
662 posix_acl_release(p);
665 EXPORT_SYMBOL_GPL(posix_acl_create);
668 * posix_acl_update_mode - update mode in set_acl
669 * @mnt_userns: user namespace of the mount @inode was found from
670 * @inode: target inode
671 * @mode_p: mode (pointer) for update
674 * Update the file mode when setting an ACL: compute the new file permission
675 * bits based on the ACL. In addition, if the ACL is equivalent to the new
676 * file mode, set *@acl to NULL to indicate that no ACL should be set.
678 * As with chmod, clear the setgid bit if the caller is not in the owning group
679 * or capable of CAP_FSETID (see inode_change_ok).
681 * If the inode has been found through an idmapped mount the user namespace of
682 * the vfsmount must be passed through @mnt_userns. This function will then
683 * take care to map the inode according to @mnt_userns before checking
684 * permissions. On non-idmapped mounts or if permission checking is to be
685 * performed on the raw inode simply passs init_user_ns.
687 * Called from set_acl inode operations.
689 int posix_acl_update_mode(struct user_namespace *mnt_userns,
690 struct inode *inode, umode_t *mode_p,
691 struct posix_acl **acl)
693 umode_t mode = inode->i_mode;
696 error = posix_acl_equiv_mode(*acl, &mode);
701 if (!vfsgid_in_group_p(i_gid_into_vfsgid(mnt_userns, inode)) &&
702 !capable_wrt_inode_uidgid(mnt_userns, inode, CAP_FSETID))
707 EXPORT_SYMBOL(posix_acl_update_mode);
710 * Fix up the uids and gids in posix acl extended attributes in place.
712 static int posix_acl_fix_xattr_common(void *value, size_t size)
714 struct posix_acl_xattr_header *header = value;
719 if (size < sizeof(struct posix_acl_xattr_header))
721 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
724 count = posix_acl_xattr_count(size);
733 void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns,
734 const struct inode *inode,
735 void *value, size_t size)
737 struct posix_acl_xattr_header *header = value;
738 struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
745 if (no_idmapping(mnt_userns, i_user_ns(inode)))
748 count = posix_acl_fix_xattr_common(value, size);
752 for (end = entry + count; entry != end; entry++) {
753 switch (le16_to_cpu(entry->e_tag)) {
755 uid = make_kuid(&init_user_ns, le32_to_cpu(entry->e_id));
756 vfsuid = make_vfsuid(mnt_userns, &init_user_ns, uid);
757 entry->e_id = cpu_to_le32(from_kuid(&init_user_ns,
758 vfsuid_into_kuid(vfsuid)));
761 gid = make_kgid(&init_user_ns, le32_to_cpu(entry->e_id));
762 vfsgid = make_vfsgid(mnt_userns, &init_user_ns, gid);
763 entry->e_id = cpu_to_le32(from_kgid(&init_user_ns,
764 vfsgid_into_kgid(vfsgid)));
772 void posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns,
773 const struct inode *inode,
774 void *value, size_t size)
776 struct posix_acl_xattr_header *header = value;
777 struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
784 if (no_idmapping(mnt_userns, i_user_ns(inode)))
787 count = posix_acl_fix_xattr_common(value, size);
791 for (end = entry + count; entry != end; entry++) {
792 switch (le16_to_cpu(entry->e_tag)) {
794 uid = make_kuid(&init_user_ns, le32_to_cpu(entry->e_id));
795 vfsuid = VFSUIDT_INIT(uid);
796 uid = from_vfsuid(mnt_userns, &init_user_ns, vfsuid);
797 entry->e_id = cpu_to_le32(from_kuid(&init_user_ns, uid));
800 gid = make_kgid(&init_user_ns, le32_to_cpu(entry->e_id));
801 vfsgid = VFSGIDT_INIT(gid);
802 gid = from_vfsgid(mnt_userns, &init_user_ns, vfsgid);
803 entry->e_id = cpu_to_le32(from_kgid(&init_user_ns, gid));
811 static void posix_acl_fix_xattr_userns(
812 struct user_namespace *to, struct user_namespace *from,
813 void *value, size_t size)
815 struct posix_acl_xattr_header *header = value;
816 struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
821 count = posix_acl_fix_xattr_common(value, size);
825 for (end = entry + count; entry != end; entry++) {
826 switch(le16_to_cpu(entry->e_tag)) {
828 uid = make_kuid(from, le32_to_cpu(entry->e_id));
829 entry->e_id = cpu_to_le32(from_kuid(to, uid));
832 gid = make_kgid(from, le32_to_cpu(entry->e_id));
833 entry->e_id = cpu_to_le32(from_kgid(to, gid));
841 void posix_acl_fix_xattr_from_user(void *value, size_t size)
843 struct user_namespace *user_ns = current_user_ns();
844 if (user_ns == &init_user_ns)
846 posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
849 void posix_acl_fix_xattr_to_user(void *value, size_t size)
851 struct user_namespace *user_ns = current_user_ns();
852 if (user_ns == &init_user_ns)
854 posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
858 * Convert from extended attribute to in-memory representation.
861 posix_acl_from_xattr(struct user_namespace *user_ns,
862 const void *value, size_t size)
864 const struct posix_acl_xattr_header *header = value;
865 const struct posix_acl_xattr_entry *entry = (const void *)(header + 1), *end;
867 struct posix_acl *acl;
868 struct posix_acl_entry *acl_e;
872 if (size < sizeof(struct posix_acl_xattr_header))
873 return ERR_PTR(-EINVAL);
874 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
875 return ERR_PTR(-EOPNOTSUPP);
877 count = posix_acl_xattr_count(size);
879 return ERR_PTR(-EINVAL);
883 acl = posix_acl_alloc(count, GFP_NOFS);
885 return ERR_PTR(-ENOMEM);
886 acl_e = acl->a_entries;
888 for (end = entry + count; entry != end; acl_e++, entry++) {
889 acl_e->e_tag = le16_to_cpu(entry->e_tag);
890 acl_e->e_perm = le16_to_cpu(entry->e_perm);
892 switch(acl_e->e_tag) {
902 le32_to_cpu(entry->e_id));
903 if (!uid_valid(acl_e->e_uid))
909 le32_to_cpu(entry->e_id));
910 if (!gid_valid(acl_e->e_gid))
921 posix_acl_release(acl);
922 return ERR_PTR(-EINVAL);
924 EXPORT_SYMBOL (posix_acl_from_xattr);
927 * Convert from in-memory to extended attribute representation.
930 posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
931 void *buffer, size_t size)
933 struct posix_acl_xattr_header *ext_acl = buffer;
934 struct posix_acl_xattr_entry *ext_entry;
937 real_size = posix_acl_xattr_size(acl->a_count);
940 if (real_size > size)
943 ext_entry = (void *)(ext_acl + 1);
944 ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
946 for (n=0; n < acl->a_count; n++, ext_entry++) {
947 const struct posix_acl_entry *acl_e = &acl->a_entries[n];
948 ext_entry->e_tag = cpu_to_le16(acl_e->e_tag);
949 ext_entry->e_perm = cpu_to_le16(acl_e->e_perm);
950 switch(acl_e->e_tag) {
953 cpu_to_le32(from_kuid(user_ns, acl_e->e_uid));
957 cpu_to_le32(from_kgid(user_ns, acl_e->e_gid));
960 ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID);
966 EXPORT_SYMBOL (posix_acl_to_xattr);
969 posix_acl_xattr_get(const struct xattr_handler *handler,
970 struct dentry *unused, struct inode *inode,
971 const char *name, void *value, size_t size)
973 struct posix_acl *acl;
976 if (!IS_POSIXACL(inode))
978 if (S_ISLNK(inode->i_mode))
981 acl = get_acl(inode, handler->flags);
987 error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
988 posix_acl_release(acl);
994 set_posix_acl(struct user_namespace *mnt_userns, struct inode *inode,
995 int type, struct posix_acl *acl)
997 if (!IS_POSIXACL(inode))
999 if (!inode->i_op->set_acl)
1002 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
1003 return acl ? -EACCES : 0;
1004 if (!inode_owner_or_capable(mnt_userns, inode))
1008 int ret = posix_acl_valid(inode->i_sb->s_user_ns, acl);
1012 return inode->i_op->set_acl(mnt_userns, inode, acl, type);
1014 EXPORT_SYMBOL(set_posix_acl);
1017 posix_acl_xattr_set(const struct xattr_handler *handler,
1018 struct user_namespace *mnt_userns,
1019 struct dentry *unused, struct inode *inode,
1020 const char *name, const void *value, size_t size,
1023 struct posix_acl *acl = NULL;
1027 acl = posix_acl_from_xattr(&init_user_ns, value, size);
1029 return PTR_ERR(acl);
1031 ret = set_posix_acl(mnt_userns, inode, handler->flags, acl);
1032 posix_acl_release(acl);
1037 posix_acl_xattr_list(struct dentry *dentry)
1039 return IS_POSIXACL(d_backing_inode(dentry));
1042 const struct xattr_handler posix_acl_access_xattr_handler = {
1043 .name = XATTR_NAME_POSIX_ACL_ACCESS,
1044 .flags = ACL_TYPE_ACCESS,
1045 .list = posix_acl_xattr_list,
1046 .get = posix_acl_xattr_get,
1047 .set = posix_acl_xattr_set,
1049 EXPORT_SYMBOL_GPL(posix_acl_access_xattr_handler);
1051 const struct xattr_handler posix_acl_default_xattr_handler = {
1052 .name = XATTR_NAME_POSIX_ACL_DEFAULT,
1053 .flags = ACL_TYPE_DEFAULT,
1054 .list = posix_acl_xattr_list,
1055 .get = posix_acl_xattr_get,
1056 .set = posix_acl_xattr_set,
1058 EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler);
1060 int simple_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
1061 struct posix_acl *acl, int type)
1065 if (type == ACL_TYPE_ACCESS) {
1066 error = posix_acl_update_mode(mnt_userns, inode,
1067 &inode->i_mode, &acl);
1072 inode->i_ctime = current_time(inode);
1073 set_cached_acl(inode, type, acl);
1077 int simple_acl_create(struct inode *dir, struct inode *inode)
1079 struct posix_acl *default_acl, *acl;
1082 error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
1086 set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl);
1087 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
1090 posix_acl_release(default_acl);
1092 posix_acl_release(acl);