Lines Matching full:acl
50 struct posix_acl *acl; in get_cached_acl() local
54 acl = rcu_dereference(*p); in get_cached_acl()
55 if (!acl || is_uncached_acl(acl) || in get_cached_acl()
56 refcount_inc_not_zero(&acl->a_refcount)) in get_cached_acl()
62 return acl; in get_cached_acl()
68 struct posix_acl *acl = rcu_dereference(*acl_by_type(inode, type)); in get_cached_acl_rcu() local
70 if (acl == ACL_DONT_CACHE) { in get_cached_acl_rcu()
75 acl = ret; in get_cached_acl_rcu()
78 return acl; in get_cached_acl_rcu()
82 void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl) in set_cached_acl() argument
87 old = xchg(p, posix_acl_dup(acl)); in set_cached_acl()
121 struct posix_acl *acl; in __get_acl() local
129 acl = get_cached_acl(inode, type); in __get_acl()
130 if (!is_uncached_acl(acl)) in __get_acl()
131 return acl; in __get_acl()
140 * If the ACL isn't being read yet, set our sentinel. Otherwise, the in __get_acl()
141 * current value of the ACL will not be ACL_NOT_CACHED and so our own in __get_acl()
144 * to just call ->get_inode_acl to fetch the ACL ourself. (This is in __get_acl()
150 * Normally, the ACL returned by ->get{_inode}_acl will be cached. in __get_acl()
154 * If the filesystem doesn't have a get{_inode}_ acl() function at all, in __get_acl()
158 acl = inode->i_op->get_acl(idmap, dentry, type); in __get_acl()
160 acl = inode->i_op->get_inode_acl(inode, type, false); in __get_acl()
165 if (IS_ERR(acl)) { in __get_acl()
168 * to cache the ACL. in __get_acl()
171 return acl; in __get_acl()
177 posix_acl_dup(acl); in __get_acl()
178 if (unlikely(!try_cmpxchg(p, &sentinel, acl))) in __get_acl()
179 posix_acl_release(acl); in __get_acl()
180 return acl; in __get_acl()
193 posix_acl_init(struct posix_acl *acl, int count) in posix_acl_init() argument
195 refcount_set(&acl->a_refcount, 1); in posix_acl_init()
196 acl->a_count = count; in posix_acl_init()
201 * Allocate a new ACL with the specified number of entries.
208 struct posix_acl *acl = kmalloc(size, flags); in posix_acl_alloc() local
209 if (acl) in posix_acl_alloc()
210 posix_acl_init(acl, count); in posix_acl_alloc()
211 return acl; in posix_acl_alloc()
216 * Clone an ACL.
219 posix_acl_clone(const struct posix_acl *acl, gfp_t flags) in posix_acl_clone() argument
223 if (acl) { in posix_acl_clone()
224 int size = sizeof(struct posix_acl) + acl->a_count * in posix_acl_clone()
226 clone = kmemdup(acl, size, flags); in posix_acl_clone()
235 * Check if an acl is valid. Returns 0 if it is, or -E... otherwise.
238 posix_acl_valid(struct user_namespace *user_ns, const struct posix_acl *acl) in posix_acl_valid() argument
244 FOREACH_ACL_ENTRY(pa, acl, pe) { in posix_acl_valid()
303 * Returns 0 if the acl can be exactly represented in the traditional
307 posix_acl_equiv_mode(const struct posix_acl *acl, umode_t *mode_p) in posix_acl_equiv_mode() argument
314 * A null ACL can always be presented as mode bits. in posix_acl_equiv_mode()
316 if (!acl) in posix_acl_equiv_mode()
319 FOREACH_ACL_ENTRY(pa, acl, pe) { in posix_acl_equiv_mode()
350 * Create an ACL representing the file mode permission bits of an inode.
355 struct posix_acl *acl = posix_acl_alloc(3, flags); in posix_acl_from_mode() local
356 if (!acl) in posix_acl_from_mode()
359 acl->a_entries[0].e_tag = ACL_USER_OBJ; in posix_acl_from_mode()
360 acl->a_entries[0].e_perm = (mode & S_IRWXU) >> 6; in posix_acl_from_mode()
362 acl->a_entries[1].e_tag = ACL_GROUP_OBJ; in posix_acl_from_mode()
363 acl->a_entries[1].e_perm = (mode & S_IRWXG) >> 3; in posix_acl_from_mode()
365 acl->a_entries[2].e_tag = ACL_OTHER; in posix_acl_from_mode()
366 acl->a_entries[2].e_perm = (mode & S_IRWXO); in posix_acl_from_mode()
367 return acl; in posix_acl_from_mode()
373 * by the acl. Returns -E... otherwise.
377 const struct posix_acl *acl, int want) in posix_acl_permission() argument
387 FOREACH_ACL_ENTRY(pa, acl, pe) { in posix_acl_permission()
447 * Modify acl when creating a new inode. The caller must ensure the acl is
451 * system calls. All permissions that are not granted by the acl are removed.
452 * The permissions in the acl are changed to reflect the mode_p parameter.
454 static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p) in posix_acl_create_masq() argument
461 /* assert(atomic_read(acl->a_refcount) == 1); */ in posix_acl_create_masq()
463 FOREACH_ACL_ENTRY(pa, acl, pe) { in posix_acl_create_masq()
509 * Modify the ACL for the chmod syscall.
511 static int __posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode) in __posix_acl_chmod_masq() argument
516 /* assert(atomic_read(acl->a_refcount) == 1); */ in __posix_acl_chmod_masq()
518 FOREACH_ACL_ENTRY(pa, acl, pe) { in __posix_acl_chmod_masq()
557 __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p) in __posix_acl_create() argument
559 struct posix_acl *clone = posix_acl_clone(*acl, gfp); in __posix_acl_create()
568 posix_acl_release(*acl); in __posix_acl_create()
569 *acl = clone; in __posix_acl_create()
575 __posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode) in __posix_acl_chmod() argument
577 struct posix_acl *clone = posix_acl_clone(*acl, gfp); in __posix_acl_chmod()
586 posix_acl_release(*acl); in __posix_acl_chmod()
587 *acl = clone; in __posix_acl_chmod()
593 * posix_acl_chmod - chmod a posix acl
610 struct posix_acl *acl; in posix_acl_chmod() local
618 acl = get_inode_acl(inode, ACL_TYPE_ACCESS); in posix_acl_chmod()
619 if (IS_ERR_OR_NULL(acl)) { in posix_acl_chmod()
620 if (acl == ERR_PTR(-EOPNOTSUPP)) in posix_acl_chmod()
622 return PTR_ERR(acl); in posix_acl_chmod()
625 ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode); in posix_acl_chmod()
628 ret = inode->i_op->set_acl(idmap, dentry, acl, ACL_TYPE_ACCESS); in posix_acl_chmod()
629 posix_acl_release(acl); in posix_acl_chmod()
636 struct posix_acl **default_acl, struct posix_acl **acl) in posix_acl_create() argument
642 *acl = NULL; in posix_acl_create()
668 *acl = clone; in posix_acl_create()
690 * @acl: acl pointer
692 * Update the file mode when setting an ACL: compute the new file permission
693 * bits based on the ACL. In addition, if the ACL is equivalent to the new
694 * file mode, set *@acl to NULL to indicate that no ACL should be set.
709 struct posix_acl **acl) in posix_acl_update_mode() argument
714 error = posix_acl_equiv_mode(*acl, &mode); in posix_acl_update_mode()
718 *acl = NULL; in posix_acl_update_mode()
728 * Fix up the uids and gids in posix acl extended attributes in place.
760 * specifically intended to be called from the acl inode operation.
766 * If it did it calling it from the get acl inode operation would return POSIX
773 * without actual POSIX ACL entries, or ERR_PTR() encoded error code.
781 struct posix_acl *acl; in posix_acl_from_xattr() local
790 acl = posix_acl_alloc(count, GFP_NOFS); in posix_acl_from_xattr()
791 if (!acl) in posix_acl_from_xattr()
793 acl_e = acl->a_entries; in posix_acl_from_xattr()
823 return acl; in posix_acl_from_xattr()
826 posix_acl_release(acl); in posix_acl_from_xattr()
835 posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, in posix_acl_to_xattr() argument
842 real_size = posix_acl_xattr_size(acl->a_count); in posix_acl_to_xattr()
851 for (n=0; n < acl->a_count; n++, ext_entry++) { in posix_acl_to_xattr()
852 const struct posix_acl_entry *acl_e = &acl->a_entries[n]; in posix_acl_to_xattr()
877 * @acl: the posix acls as represented by the vfs
878 * @buffer: the buffer into which to convert @acl
881 * This converts @acl from the VFS representation in the filesystem idmapping
890 const struct posix_acl *acl, void *buffer, in vfs_posix_acl_to_xattr() argument
901 real_size = posix_acl_xattr_size(acl->a_count); in vfs_posix_acl_to_xattr()
912 for (n=0; n < acl->a_count; n++, ext_entry++) { in vfs_posix_acl_to_xattr()
913 const struct posix_acl_entry *acl_e = &acl->a_entries[n]; in vfs_posix_acl_to_xattr()
937 int type, struct posix_acl *acl) in set_posix_acl() argument
947 return acl ? -EACCES : 0; in set_posix_acl()
951 if (acl) { in set_posix_acl()
952 int ret = posix_acl_valid(inode->i_sb->s_user_ns, acl); in set_posix_acl()
956 return inode->i_op->set_acl(idmap, dentry, acl, type); in set_posix_acl()
994 * This is the legacy POSIX ACL access xattr handler. It is used by some
1007 * This is the legacy POSIX ACL default xattr handler. It is used by some
1018 struct posix_acl *acl, int type) in simple_set_acl() argument
1025 &inode->i_mode, &acl); in simple_set_acl()
1033 set_cached_acl(inode, type, acl); in simple_set_acl()
1039 struct posix_acl *default_acl, *acl; in simple_acl_create() local
1042 error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); in simple_acl_create()
1047 set_cached_acl(inode, ACL_TYPE_ACCESS, acl); in simple_acl_create()
1051 if (acl) in simple_acl_create()
1052 posix_acl_release(acl); in simple_acl_create()
1058 struct posix_acl *acl) in vfs_set_acl_idmapped_mnt() argument
1060 for (int n = 0; n < acl->a_count; n++) { in vfs_set_acl_idmapped_mnt()
1061 struct posix_acl_entry *acl_e = &acl->a_entries[n]; in vfs_set_acl_idmapped_mnt()
1082 * @acl_name: the name of the posix acl
1160 * @acl_name: the name of the posix acl
1171 struct posix_acl *acl; in vfs_get_acl() local
1191 acl = __get_acl(idmap, dentry, inode, acl_type); in vfs_get_acl()
1192 if (IS_ERR(acl)) in vfs_get_acl()
1193 return acl; in vfs_get_acl()
1194 if (!acl) in vfs_get_acl()
1197 return acl; in vfs_get_acl()
1205 * @acl_name: the name of the posix acl
1268 struct posix_acl *acl = NULL; in do_set_acl() local
1275 acl = posix_acl_from_xattr(current_user_ns(), kvalue, size); in do_set_acl()
1276 if (IS_ERR(acl)) in do_set_acl()
1277 return PTR_ERR(acl); in do_set_acl()
1280 error = vfs_set_acl(idmap, dentry, acl_name, acl); in do_set_acl()
1281 posix_acl_release(acl); in do_set_acl()
1289 struct posix_acl *acl; in do_get_acl() local
1291 acl = vfs_get_acl(idmap, dentry, acl_name); in do_get_acl()
1292 if (IS_ERR(acl)) in do_get_acl()
1293 return PTR_ERR(acl); in do_get_acl()
1296 acl, kvalue, size); in do_get_acl()
1297 posix_acl_release(acl); in do_get_acl()