Lines Matching +full:label +full:- +full:revision

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 1998-2008 Novell/SUSE
8 * Copyright 2009-2010 Canonical Ltd.
34 #include "include/label.h"
82 aa_put_loaddata(private->loaddata);
90 if (size > SIZE_MAX - sizeof(*ret))
91 return ERR_PTR(-EINVAL);
95 return ERR_PTR(-ENOMEM);
102 * mangle_name - mangle a profile name to std profile layout form
121 else if (isalnum(*name) || strchr("._-", *name))
130 strchr("/._-", *name))
137 return t - target;
142 * aafs - core fns and data for the policy tree
152 seq_printf(seq, "%s:[%lu]", AAFS_NAME, d_inode(dentry)->i_ino);
158 if (S_ISLNK(inode->i_mode))
159 kfree(inode->i_link);
177 sb->s_op = &aafs_super_ops;
193 fc->ops = &apparmorfs_context_ops;
205 * __aafs_setup_d_inode - basic inode setup for apparmorfs
219 struct inode *inode = new_inode(dir->i_sb);
225 return -ENOMEM;
227 inode->i_ino = get_next_ino();
228 inode->i_mode = mode;
230 inode->i_private = data;
232 inode->i_op = iops ? iops : &simple_dir_inode_operations;
233 inode->i_fop = &simple_dir_operations;
237 inode->i_op = iops ? iops : &simple_symlink_inode_operations;
238 inode->i_link = link;
240 inode->i_fop = fops;
249 * aafs_create - create a dentry in the apparmorfs filesystem
293 error = -EEXIST;
315 * aafs_create_file - create a file in the apparmorfs filesystem
333 * aafs_create_dir - create a directory in the apparmorfs filesystem
347 * aafs_remove - removes a file or directory from the apparmorfs filesystem
358 dir = d_inode(dentry->d_parent);
374 * aa_fs - policy load/replace/remove
378 * aa_simple_write_to_buffer - common routine for getting policy from user
398 return ERR_PTR(-ESPIPE);
405 data->size = copy_size;
406 if (copy_from_user(data->data, userbuf, copy_size)) {
408 return ERR_PTR(-EFAULT);
418 struct aa_label *label;
421 label = begin_current_label_crit_section();
423 /* high level check about policy management - fine grained in
426 error = aa_may_manage_policy(current_cred(), label, ns, mask);
433 error = aa_replace_profiles(ns, label, mask, data);
437 end_current_label_crit_section(label);
446 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private);
463 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private);
481 struct aa_label *label;
483 struct aa_ns *ns = aa_get_ns(f->f_inode->i_private);
485 label = begin_current_label_crit_section();
486 /* high level check about policy management - fine grained in
489 error = aa_may_manage_policy(current_cred(), label, ns,
502 data->data[size] = 0;
503 error = aa_remove_profiles(ns, label, data->data, size);
507 end_current_label_crit_section(label);
522 /* revision file hook fn for policy loads */
525 struct aa_revision *rev = file->private_data;
528 aa_put_ns(rev->ns);
538 struct aa_revision *rev = file->private_data;
543 mutex_lock_nested(&rev->ns->lock, rev->ns->level);
544 last_read = rev->last_read;
545 if (last_read == rev->ns->revision) {
546 mutex_unlock(&rev->ns->lock);
547 if (file->f_flags & O_NONBLOCK)
548 return -EAGAIN;
549 if (wait_event_interruptible(rev->ns->wait,
551 READ_ONCE(rev->ns->revision)))
552 return -ERESTARTSYS;
553 mutex_lock_nested(&rev->ns->lock, rev->ns->level);
556 avail = sprintf(buffer, "%ld\n", rev->ns->revision);
558 rev->last_read = rev->ns->revision;
561 mutex_unlock(&rev->ns->lock);
571 return -ENOMEM;
573 rev->ns = aa_get_ns(inode->i_private);
574 if (!rev->ns)
575 rev->ns = aa_get_current_ns();
576 file->private_data = rev;
583 struct aa_revision *rev = file->private_data;
587 mutex_lock_nested(&rev->ns->lock, rev->ns->level);
588 poll_wait(file, &rev->ns->wait, pt);
589 if (rev->last_read < rev->ns->revision)
591 mutex_unlock(&rev->ns->lock);
599 WRITE_ONCE(ns->revision, READ_ONCE(ns->revision) + 1);
600 wake_up_interruptible(&ns->wait);
615 struct aa_ruleset *rules = list_first_entry(&profile->rules,
622 if (rules->file->dfa && *match_str == AA_CLASS_FILE) {
623 state = aa_dfa_match_len(rules->file->dfa,
624 rules->file->start[AA_CLASS_FILE],
625 match_str + 1, match_len - 1);
629 tmp = *(aa_lookup_fperms(rules->file, state, &cond));
631 } else if (rules->policy->dfa) {
634 state = aa_dfa_match_len(rules->policy->dfa,
635 rules->policy->start[0],
638 tmp = *aa_lookup_perms(rules->policy, state);
646 * query_data - queries a policy and writes its data to buf
655 * The query should look like "<LABEL>\0<KEY>\0", where <LABEL> is the name of
657 * retrieve. <LABEL> and <KEY> must not be NUL-terminated.
661 * Returns: number of characters written to buf or -errno on failure
669 struct aa_label *label, *curr;
676 return -EINVAL; /* need a query */
680 return -EINVAL; /* not enough space for a non-empty key */
681 if (key + strnlen(key, query + query_len - key) >= query + query_len)
682 return -EINVAL; /* must end with NUL */
685 return -EINVAL; /* not enough space */
688 label = aa_label_parse(curr, query, GFP_KERNEL, false, false);
690 if (IS_ERR(label))
691 return PTR_ERR(label);
705 label_for_each_confined(i, label, profile) {
706 if (!profile->data)
709 data = rhashtable_lookup_fast(profile->data, &key,
710 profile->data->p);
713 if (out + sizeof(outle32) + data->size > buf +
715 aa_put_label(label);
716 return -EINVAL; /* not enough space */
718 outle32 = __cpu_to_le32(data->size);
721 memcpy(out, data->data, data->size);
722 out += data->size;
726 aa_put_label(label);
728 outle32 = __cpu_to_le32(out - buf - sizeof(bytes));
733 return out - buf;
737 * query_label - queries a label and writes permissions to buf
748 * the name of the label, in the current namespace, that is to be queried and
749 * DFA_STRING is a binary string to match against the label(s)'s DFA.
754 * Returns: number of characters written to buf or -errno on failure
760 struct aa_label *label, *curr;
767 return -EINVAL;
772 return -EINVAL;
781 match_len = query_len - label_name_len - 1;
784 label = aa_label_parse(curr, label_name, GFP_KERNEL, false, false);
786 if (IS_ERR(label))
787 return PTR_ERR(label);
791 label_for_each_in_ns(i, labels_ns(label), label, profile) {
795 label_for_each(i, label, profile) {
799 aa_put_label(label);
809 * possibly a read(s) which collects the result - which is stored in a
810 * file-local buffer. Once a new write is performed, a new set of results
811 * are stored in the file-local buffer.
819 #define MULTI_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct multi_transaction))
833 kref_get(&(t->count));
841 kref_put(&(t->count), multi_transaction_kref);
852 new->size = n;
853 spin_lock(&file->f_lock);
854 old = (struct multi_transaction *) file->private_data;
855 file->private_data = new;
856 spin_unlock(&file->f_lock);
866 if (size > MULTI_TRANSACTION_LIMIT - 1)
867 return ERR_PTR(-EFBIG);
871 return ERR_PTR(-ENOMEM);
872 kref_init(&t->count);
873 if (copy_from_user(t->data, buf, size)) {
875 return ERR_PTR(-EFAULT);
887 spin_lock(&file->f_lock);
888 t = get_multi_transaction(file->private_data);
889 spin_unlock(&file->f_lock);
894 ret = simple_read_from_buffer(buf, size, pos, t->data, t->size);
902 put_multi_transaction(file->private_data);
907 #define QUERY_CMD_LABEL "label\0"
917 * aa_write_access - generic permissions and data query
924 * sequence. The only queries currently supported are label-based queries for
927 * For permissions queries, ubuf must begin with "label\0", followed by the
931 * For data queries, ubuf must have the form "data\0<LABEL>\0<KEY>\0", where
932 * <LABEL> is the name of the security confinement context and <KEY> is the
935 * Returns: number of bytes written or -errno on failure
944 return -ESPIPE;
951 !memcmp(t->data, QUERY_CMD_PROFILE, QUERY_CMD_PROFILE_LEN)) {
952 len = query_label(t->data, MULTI_TRANSACTION_LIMIT,
953 t->data + QUERY_CMD_PROFILE_LEN,
954 count - QUERY_CMD_PROFILE_LEN, true);
956 !memcmp(t->data, QUERY_CMD_LABEL, QUERY_CMD_LABEL_LEN)) {
957 len = query_label(t->data, MULTI_TRANSACTION_LIMIT,
958 t->data + QUERY_CMD_LABEL_LEN,
959 count - QUERY_CMD_LABEL_LEN, true);
961 !memcmp(t->data, QUERY_CMD_LABELALL,
963 len = query_label(t->data, MULTI_TRANSACTION_LIMIT,
964 t->data + QUERY_CMD_LABELALL_LEN,
965 count - QUERY_CMD_LABELALL_LEN, false);
967 !memcmp(t->data, QUERY_CMD_DATA, QUERY_CMD_DATA_LEN)) {
968 len = query_data(t->data, MULTI_TRANSACTION_LIMIT,
969 t->data + QUERY_CMD_DATA_LEN,
970 count - QUERY_CMD_DATA_LEN);
972 len = -EINVAL;
993 struct aa_sfs_entry *fs_file = seq->private;
998 switch (fs_file->v_type) {
1000 seq_printf(seq, "%s\n", fs_file->v.boolean ? "yes" : "no");
1003 seq_printf(seq, "%s\n", fs_file->v.string);
1006 seq_printf(seq, "%#08lx\n", fs_file->v.u64);
1018 return single_open(file, aa_sfs_seq_show, inode->i_private);
1051 struct aa_proxy *proxy = aa_get_proxy(inode->i_private);
1055 file->private_data = NULL;
1064 struct seq_file *seq = (struct seq_file *) file->private_data;
1066 aa_put_proxy(seq->private);
1072 struct aa_proxy *proxy = seq->private;
1073 struct aa_label *label = aa_get_label_rcu(&proxy->label);
1074 struct aa_profile *profile = labels_profile(label);
1075 seq_printf(seq, "%s\n", profile->base.name);
1076 aa_put_label(label);
1083 struct aa_proxy *proxy = seq->private;
1084 struct aa_label *label = aa_get_label_rcu(&proxy->label);
1085 struct aa_profile *profile = labels_profile(label);
1086 seq_printf(seq, "%s\n", aa_profile_mode_names[profile->mode]);
1087 aa_put_label(label);
1094 struct aa_proxy *proxy = seq->private;
1095 struct aa_label *label = aa_get_label_rcu(&proxy->label);
1096 struct aa_profile *profile = labels_profile(label);
1097 if (profile->attach.xmatch_str)
1098 seq_printf(seq, "%s\n", profile->attach.xmatch_str);
1099 else if (profile->attach.xmatch->dfa)
1102 seq_printf(seq, "%s\n", profile->base.name);
1103 aa_put_label(label);
1110 struct aa_proxy *proxy = seq->private;
1111 struct aa_label *label = aa_get_label_rcu(&proxy->label);
1112 struct aa_profile *profile = labels_profile(label);
1115 if (profile->hash) {
1117 seq_printf(seq, "%.2x", profile->hash[i]);
1120 aa_put_label(label);
1139 return single_open(file, seq_ns_ ##NAME ##_show, inode->i_private); \
1152 struct aa_label *label;
1154 label = begin_current_label_crit_section();
1155 seq_printf(seq, "%s\n", label->size > 1 ? "yes" : "no");
1156 end_current_label_crit_section(label);
1163 struct aa_label *label;
1168 label = begin_current_label_crit_section();
1170 if (label->size > 1) {
1171 label_for_each(it, label, profile)
1172 if (profile->ns != labels_ns(label)) {
1179 end_current_label_crit_section(label);
1186 struct aa_label *label;
1188 label = begin_current_label_crit_section();
1189 seq_printf(seq, "%d\n", labels_ns(label)->level);
1190 end_current_label_crit_section(label);
1197 struct aa_label *label = begin_current_label_crit_section();
1198 seq_printf(seq, "%s\n", labels_ns(label)->base.name);
1199 end_current_label_crit_section(label);
1243 struct aa_loaddata *data = __aa_get_loaddata(inode->i_private);
1248 return -ENOENT;
1252 AA_BUG(file->private_data &&
1253 ((struct seq_file *)file->private_data)->private);
1262 struct seq_file *seq = (struct seq_file *) file->private_data;
1265 aa_put_loaddata(seq->private);
1272 struct aa_loaddata *data = seq->private;
1274 seq_printf(seq, "v%d\n", data->abi);
1281 struct aa_loaddata *data = seq->private;
1283 seq_printf(seq, "%ld\n", data->revision);
1290 struct aa_loaddata *data = seq->private;
1293 if (data->hash) {
1295 seq_printf(seq, "%.2x", data->hash[i]);
1304 struct aa_loaddata *data = seq->private;
1306 seq_printf(seq, "%zu\n", data->compressed_size);
1312 SEQ_RAWDATA_FOPS(revision);
1327 ret = -ENOMEM;
1332 ret = -ENOMEM;
1337 ret = -EINVAL;
1346 return -EINVAL;
1354 struct rawdata_f_data *private = file->private_data;
1358 private->loaddata->size);
1363 rawdata_f_data_free(file->private_data);
1375 return -EACCES;
1377 loaddata = __aa_get_loaddata(inode->i_private);
1380 return -ENOENT;
1382 private = rawdata_f_data_alloc(loaddata->size);
1388 private->loaddata = loaddata;
1390 error = decompress_zstd(loaddata->data, loaddata->compressed_size,
1392 loaddata->size);
1396 file->private_data = private;
1420 if (!IS_ERR_OR_NULL(rawdata->dents[i])) {
1422 aafs_remove(rawdata->dents[i]);
1423 rawdata->dents[i] = NULL;
1430 AA_BUG(rawdata->ns && !mutex_is_locked(&rawdata->ns->lock));
1432 if (rawdata->ns) {
1434 list_del_init(&rawdata->list);
1435 aa_put_ns(rawdata->ns);
1436 rawdata->ns = NULL;
1446 AA_BUG(!mutex_is_locked(&ns->lock));
1450 * just use ns revision dir was originally created at. This is
1451 * under ns->lock and if load is successful revision will be
1454 rawdata->name = kasprintf(GFP_KERNEL, "%ld", ns->revision);
1455 if (!rawdata->name)
1456 return -ENOMEM;
1458 dir = aafs_create_dir(rawdata->name, ns_subdata_dir(ns));
1460 /* ->name freed when rawdata freed */
1462 rawdata->dents[AAFS_LOADDATA_DIR] = dir;
1468 rawdata->dents[AAFS_LOADDATA_ABI] = dent;
1470 dent = aafs_create_file("revision", S_IFREG | 0444, dir, rawdata,
1474 rawdata->dents[AAFS_LOADDATA_REVISION] = dent;
1481 rawdata->dents[AAFS_LOADDATA_HASH] = dent;
1489 rawdata->dents[AAFS_LOADDATA_COMPRESSED_SIZE] = dent;
1495 rawdata->dents[AAFS_LOADDATA_DATA] = dent;
1496 d_inode(dent)->i_size = rawdata->size;
1498 rawdata->ns = aa_get_ns(ns);
1499 list_add(&rawdata->list, &ns->rawdata_list);
1516 * Requires: @profile->ns->lock held
1526 list_for_each_entry(child, &profile->base.profiles, base.list)
1529 for (i = AAFS_PROF_SIZEOF - 1; i >= 0; --i) {
1531 if (!profile->dents[i])
1534 proxy = d_inode(profile->dents[i])->i_private;
1535 aafs_remove(profile->dents[i]);
1537 profile->dents[i] = NULL;
1543 * Requires: @old->ns->lock held
1552 AA_BUG(!mutex_is_locked(&profiles_ns(old)->lock));
1555 new->dents[i] = old->dents[i];
1556 if (new->dents[i]) {
1557 struct inode *inode = d_inode(new->dents[i]);
1562 old->dents[i] = NULL;
1570 struct aa_proxy *proxy = aa_get_proxy(profile->label.proxy);
1586 for (depth = 0; profile; profile = rcu_access_pointer(profile->parent))
1601 return ERR_PTR(-ENOMEM);
1603 for (; depth > 0; depth--) {
1606 size -= 6;
1612 return ERR_PTR(-ENAMETOOLONG);
1623 struct aa_proxy *proxy = inode->i_private;
1624 struct aa_label *label;
1630 return ERR_PTR(-ECHILD);
1632 label = aa_get_label_rcu(&proxy->label);
1633 profile = labels_profile(label);
1635 target = gen_symlink_name(depth, profile->rawdata->name, name);
1636 aa_put_label(label);
1680 * Requires: @profile->ns->lock held
1689 AA_BUG(!mutex_is_locked(&profiles_ns(profile)->lock));
1696 error = -ENOENT;
1706 if (!profile->dirname) {
1708 len = mangle_name(profile->base.name, NULL);
1709 id_len = snprintf(NULL, 0, ".%ld", profile->ns->uniq_id);
1711 profile->dirname = kmalloc(len + id_len + 1, GFP_KERNEL);
1712 if (!profile->dirname) {
1713 error = -ENOMEM;
1717 mangle_name(profile->base.name, profile->dirname);
1718 sprintf(profile->dirname + len, ".%ld", profile->ns->uniq_id++);
1721 dent = aafs_create_dir(profile->dirname, parent);
1730 profile->dents[AAFS_PROF_NAME] = dent;
1736 profile->dents[AAFS_PROF_MODE] = dent;
1742 profile->dents[AAFS_PROF_ATTACH] = dent;
1744 if (profile->hash) {
1749 profile->dents[AAFS_PROF_HASH] = dent;
1753 if (profile->rawdata) {
1756 profile->label.proxy, NULL, NULL,
1760 aa_get_proxy(profile->label.proxy);
1761 profile->dents[AAFS_PROF_RAW_HASH] = dent;
1764 profile->label.proxy, NULL, NULL,
1768 aa_get_proxy(profile->label.proxy);
1769 profile->dents[AAFS_PROF_RAW_ABI] = dent;
1772 profile->label.proxy, NULL, NULL,
1776 aa_get_proxy(profile->label.proxy);
1777 profile->dents[AAFS_PROF_RAW_DATA] = dent;
1781 list_for_each_entry(child, &profile->base.profiles, base.list) {
1803 struct aa_label *label;
1806 label = begin_current_label_crit_section();
1807 error = aa_may_manage_policy(current_cred(), label, NULL,
1809 end_current_label_crit_section(label);
1813 parent = aa_get_ns(dir->i_private);
1821 mutex_lock_nested(&parent->lock, parent->level);
1831 ns = __aa_find_or_create_ns(parent, READ_ONCE(dentry->d_name.name),
1843 mutex_unlock(&parent->lock);
1853 struct aa_label *label;
1856 label = begin_current_label_crit_section();
1857 error = aa_may_manage_policy(current_cred(), label, NULL,
1859 end_current_label_crit_section(label);
1863 parent = aa_get_ns(dir->i_private);
1869 inode_unlock(dentry->d_inode);
1871 mutex_lock_nested(&parent->lock, parent->level);
1872 ns = aa_get_ns(__aa_findn_ns(&parent->sub_ns, dentry->d_name.name,
1873 dentry->d_name.len));
1875 error = -ENOENT;
1884 mutex_unlock(&parent->lock);
1886 inode_lock(dentry->d_inode);
1902 AA_BUG(!mutex_is_locked(&ns->lock));
1904 list_for_each_entry_safe(ent, tmp, &ns->rawdata_list, list)
1910 * Requires: @ns->lock held
1920 AA_BUG(!mutex_is_locked(&ns->lock));
1922 list_for_each_entry(child, &ns->base.profiles, base.list)
1925 list_for_each_entry(sub, &ns->sub_ns, base.list) {
1926 mutex_lock_nested(&sub->lock, sub->level);
1928 mutex_unlock(&sub->lock);
1934 sub = d_inode(ns_subns_dir(ns))->i_private;
1938 sub = d_inode(ns_subload(ns))->i_private;
1942 sub = d_inode(ns_subreplace(ns))->i_private;
1946 sub = d_inode(ns_subremove(ns))->i_private;
1950 sub = d_inode(ns_subrevision(ns))->i_private;
1954 for (i = AAFS_NS_SIZEOF - 1; i >= 0; --i) {
1955 aafs_remove(ns->dents[i]);
1956 ns->dents[i] = NULL;
1978 dent = aafs_create_file("revision", 0444, dir, ns,
2018 * Requires: @ns->lock held
2030 AA_BUG(!mutex_is_locked(&ns->lock));
2033 name = ns->base.name;
2048 list_for_each_entry(child, &ns->base.profiles, base.list) {
2055 list_for_each_entry(sub, &ns->sub_ns, base.list) {
2056 mutex_lock_nested(&sub->lock, sub->level);
2058 mutex_unlock(&sub->lock);
2075 * __next_ns - find the next namespace to list
2083 * Requires: ns->parent->lock to be held
2084 * NOTE: will not unlock root->lock
2092 AA_BUG(ns != root && !mutex_is_locked(&ns->parent->lock));
2095 if (!list_empty(&ns->sub_ns)) {
2096 next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
2097 mutex_lock_nested(&next->lock, next->level);
2102 parent = ns->parent;
2104 mutex_unlock(&ns->lock);
2106 if (!list_entry_is_head(next, &parent->sub_ns, base.list)) {
2107 mutex_lock_nested(&next->lock, next->level);
2111 parent = parent->parent;
2118 * __first_profile - find the first profile in a namespace
2123 * Requires: profile->ns.lock to be held
2129 AA_BUG(ns && !mutex_is_locked(&ns->lock));
2132 if (!list_empty(&ns->base.profiles))
2133 return list_first_entry(&ns->base.profiles,
2140 * __next_profile - step to the next profile in a profile tree
2146 * Requires: profile->ns.lock to be held
2151 struct aa_ns *ns = p->ns;
2153 AA_BUG(!mutex_is_locked(&profiles_ns(p)->lock));
2156 if (!list_empty(&p->base.profiles))
2157 return list_first_entry(&p->base.profiles, typeof(*p),
2161 parent = rcu_dereference_protected(p->parent,
2162 mutex_is_locked(&p->ns->lock));
2165 if (!list_entry_is_head(p, &parent->base.profiles, base.list))
2168 parent = rcu_dereference_protected(parent->parent,
2169 mutex_is_locked(&parent->ns->lock));
2174 if (!list_entry_is_head(p, &ns->base.profiles, base.list))
2181 * next_profile - step to the next profile in where ever it may be
2195 return __first_profile(root, __next_ns(root, profile->ns));
2199 * p_start - start a depth first traversal of profile tree
2205 * acquires first ns->lock
2212 f->private = root;
2215 mutex_lock_nested(&root->lock, root->level);
2219 for (; profile && l > 0; l--)
2226 * p_next - read the next profile entry
2238 struct aa_ns *ns = f->private;
2245 * p_stop - stop depth first traversal
2254 struct aa_ns *root = f->private, *ns;
2257 for (ns = profile->ns; ns && ns != root; ns = ns->parent)
2258 mutex_unlock(&ns->lock);
2260 mutex_unlock(&root->lock);
2265 * seq_show_profile - show a profile entry
2274 struct aa_ns *root = f->private;
2276 aa_label_seq_xprint(f, root, &profile->label,
2293 return -EACCES;
2361 #define PERMS32STR "allow deny subtree cond kill complain prompt audit quiet hide xindex tag label"
2395 AA_SFS_DIR("label", aa_sfs_entry_query_label),
2438 * entry_create_file - create a file entry in the apparmor securityfs
2449 fs_file->dentry = securityfs_create_file(fs_file->name,
2450 S_IFREG | fs_file->mode,
2452 fs_file->file_ops);
2453 if (IS_ERR(fs_file->dentry)) {
2454 error = PTR_ERR(fs_file->dentry);
2455 fs_file->dentry = NULL;
2462 * entry_create_dir - recursively create a directory entry in the securityfs
2475 dir = securityfs_create_dir(fs_dir->name, parent);
2478 fs_dir->dentry = dir;
2480 for (fs_file = fs_dir->v.files; fs_file && fs_file->name; ++fs_file) {
2481 if (fs_file->v_type == AA_SFS_TYPE_DIR)
2482 error = entry_create_dir(fs_file, fs_dir->dentry);
2484 error = entry_create_file(fs_file, fs_dir->dentry);
2498 * entry_remove_file - drop a single file entry in the apparmor securityfs
2503 if (!fs_file->dentry)
2506 securityfs_remove(fs_file->dentry);
2507 fs_file->dentry = NULL;
2511 * entry_remove_dir - recursively drop a directory entry from the securityfs
2518 for (fs_file = fs_dir->v.files; fs_file && fs_file->name; ++fs_file) {
2519 if (fs_file->v_type == AA_SFS_TYPE_DIR)
2529 * aa_destroy_aafs - cleanup and free aafs
2548 int error = simple_pin_fs(parent->d_sb->s_type, &mount, &count);
2559 inode = new_inode(parent->d_inode->i_sb);
2561 error = -ENOMEM;
2565 inode->i_ino = get_next_ino();
2566 inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO;
2595 return ERR_PTR(-ECHILD);
2613 d_inode(dentry)->i_ino);
2617 res = -ENOENT;
2629 * aa_create_aafs - create the apparmor security filesystem
2645 return -EEXIST;
2652 aafs_mnt->mnt_sb->s_flags &= ~SB_NOUSER;
2677 dent = securityfs_create_file("revision", 0444, aa_sfs_entry.dentry,
2684 mutex_lock_nested(&root_ns->lock, root_ns->level);
2685 error = __aafs_ns_mkdir(root_ns, aafs_mnt->mnt_root, ".policy",
2686 aafs_mnt->mnt_root);
2687 mutex_unlock(&root_ns->lock);