Lines Matching full:tree

61  * the same tree.
68 * tree.chunks anchors chunk.owners[].list hash_lock
69 * tree.rules anchors rule.rlist audit_filter_mutex
70 * chunk.trees anchors tree.same_root hash_lock
74 * tree is refcounted; one reference for "some rules on rules_list refer to
95 struct audit_tree *tree; in alloc_tree() local
97 tree = kmalloc(struct_size(tree, pathname, strlen(s) + 1), GFP_KERNEL); in alloc_tree()
98 if (tree) { in alloc_tree()
99 refcount_set(&tree->count, 1); in alloc_tree()
100 tree->goner = 0; in alloc_tree()
101 INIT_LIST_HEAD(&tree->chunks); in alloc_tree()
102 INIT_LIST_HEAD(&tree->rules); in alloc_tree()
103 INIT_LIST_HEAD(&tree->list); in alloc_tree()
104 INIT_LIST_HEAD(&tree->same_root); in alloc_tree()
105 tree->root = NULL; in alloc_tree()
106 strcpy(tree->pathname, s); in alloc_tree()
108 return tree; in alloc_tree()
111 static inline void get_tree(struct audit_tree *tree) in get_tree() argument
113 refcount_inc(&tree->count); in get_tree()
116 static inline void put_tree(struct audit_tree *tree) in put_tree() argument
118 if (refcount_dec_and_test(&tree->count)) in put_tree()
119 kfree_rcu(tree, head); in put_tree()
123 const char *audit_tree_path(struct audit_tree *tree) in audit_tree_path() argument
125 return tree->pathname; in audit_tree_path()
261 bool audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) in audit_tree_match() argument
265 if (chunk->owners[n].owner == tree) in audit_tree_match()
397 static int create_chunk(struct inode *inode, struct audit_tree *tree) in create_chunk() argument
422 if (tree->goner) { in create_chunk()
433 chunk->owners[0].owner = tree; in create_chunk()
434 get_tree(tree); in create_chunk()
435 list_add(&chunk->owners[0].list, &tree->chunks); in create_chunk()
436 if (!tree->root) { in create_chunk()
437 tree->root = chunk; in create_chunk()
438 list_add(&tree->same_root, &chunk->trees); in create_chunk()
457 /* the first tagged inode becomes root of tree */
458 static int tag_chunk(struct inode *inode, struct audit_tree *tree) in tag_chunk() argument
468 return create_chunk(inode, tree); in tag_chunk()
479 if (old->owners[n].owner == tree) { in tag_chunk()
496 if (tree->goner) { in tag_chunk()
505 p->owner = tree; in tag_chunk()
506 get_tree(tree); in tag_chunk()
507 list_add(&p->list, &tree->chunks); in tag_chunk()
508 if (!tree->root) { in tag_chunk()
509 tree->root = chunk; in tag_chunk()
510 list_add(&tree->same_root, &chunk->trees); in tag_chunk()
536 audit_log_untrustedstring(ab, rule->tree->pathname); in audit_tree_log_remove_rule()
542 static void kill_rules(struct audit_context *context, struct audit_tree *tree) in kill_rules() argument
547 list_for_each_entry_safe(rule, next, &tree->rules, rlist) { in kill_rules()
551 if (rule->tree) { in kill_rules()
556 rule->tree = NULL; in kill_rules()
565 * Remove tree from chunks. If 'tagged' is set, remove tree only from tagged
607 /* trim the uncommitted chunks from tree */
609 static void trim_marked(struct audit_tree *tree) in trim_marked() argument
613 if (tree->goner) { in trim_marked()
618 for (p = tree->chunks.next; p != &tree->chunks; p = q) { in trim_marked()
623 list_add(p, &tree->chunks); in trim_marked()
628 prune_tree_chunks(tree, true); in trim_marked()
631 if (!tree->root && !tree->goner) { in trim_marked()
632 tree->goner = 1; in trim_marked()
635 kill_rules(audit_context(), tree); in trim_marked()
636 list_del_init(&tree->list); in trim_marked()
638 prune_one(tree); in trim_marked()
649 struct audit_tree *tree; in audit_remove_tree_rule() local
650 tree = rule->tree; in audit_remove_tree_rule()
651 if (tree) { in audit_remove_tree_rule()
654 if (list_empty(&tree->rules) && !tree->goner) { in audit_remove_tree_rule()
655 tree->root = NULL; in audit_remove_tree_rule()
656 list_del_init(&tree->same_root); in audit_remove_tree_rule()
657 tree->goner = 1; in audit_remove_tree_rule()
658 list_move(&tree->list, &prune_list); in audit_remove_tree_rule()
659 rule->tree = NULL; in audit_remove_tree_rule()
664 rule->tree = NULL; in audit_remove_tree_rule()
684 struct audit_tree *tree; in audit_trim_trees() local
690 tree = container_of(cursor.next, struct audit_tree, list); in audit_trim_trees()
691 get_tree(tree); in audit_trim_trees()
692 list_move(&cursor, &tree->list); in audit_trim_trees()
695 err = kern_path(tree->pathname, 0, &path); in audit_trim_trees()
705 list_for_each_entry(node, &tree->chunks, list) { in audit_trim_trees()
715 trim_marked(tree); in audit_trim_trees()
718 put_tree(tree); in audit_trim_trees()
732 rule->inode_f || rule->watch || rule->tree) in audit_make_tree()
734 rule->tree = alloc_tree(pathname); in audit_make_tree()
735 if (!rule->tree) in audit_make_tree()
740 void audit_put_tree(struct audit_tree *tree) in audit_put_tree() argument
742 put_tree(tree); in audit_put_tree()
802 struct audit_tree *seed = rule->tree, *tree; in audit_add_tree_rule() local
807 rule->tree = NULL; in audit_add_tree_rule()
808 list_for_each_entry(tree, &tree_list, list) { in audit_add_tree_rule()
809 if (!strcmp(seed->pathname, tree->pathname)) { in audit_add_tree_rule()
811 rule->tree = tree; in audit_add_tree_rule()
812 list_add(&rule->rlist, &tree->rules); in audit_add_tree_rule()
816 tree = seed; in audit_add_tree_rule()
817 list_add(&tree->list, &tree_list); in audit_add_tree_rule()
818 list_add(&rule->rlist, &tree->rules); in audit_add_tree_rule()
819 /* do not set rule->tree yet */ in audit_add_tree_rule()
828 err = kern_path(tree->pathname, 0, &path); in audit_add_tree_rule()
838 get_tree(tree); in audit_add_tree_rule()
839 err = iterate_mounts(tag_mount, tree, mnt); in audit_add_tree_rule()
845 list_for_each_entry(node, &tree->chunks, list) in audit_add_tree_rule()
849 trim_marked(tree); in audit_add_tree_rule()
855 put_tree(tree); in audit_add_tree_rule()
858 rule->tree = tree; in audit_add_tree_rule()
859 put_tree(tree); in audit_add_tree_rule()
864 list_del_init(&tree->list); in audit_add_tree_rule()
865 list_del_init(&tree->rules); in audit_add_tree_rule()
866 put_tree(tree); in audit_add_tree_rule()
897 struct audit_tree *tree; in audit_tag_tree() local
900 tree = container_of(cursor.next, struct audit_tree, list); in audit_tag_tree()
901 get_tree(tree); in audit_tag_tree()
902 list_move(&cursor, &tree->list); in audit_tag_tree()
905 err = kern_path(tree->pathname, 0, &path2); in audit_tag_tree()
912 put_tree(tree); in audit_tag_tree()
917 failed = iterate_mounts(tag_mount, tree, tagged); in audit_tag_tree()
919 put_tree(tree); in audit_tag_tree()
926 if (!tree->goner) { in audit_tag_tree()
927 list_move(&tree->list, &tree_list); in audit_tag_tree()
930 put_tree(tree); in audit_tag_tree()
934 struct audit_tree *tree; in audit_tag_tree() local
936 tree = container_of(barrier.prev, struct audit_tree, list); in audit_tag_tree()
937 get_tree(tree); in audit_tag_tree()
938 list_move(&tree->list, &barrier); in audit_tag_tree()
944 list_for_each_entry(node, &tree->chunks, list) in audit_tag_tree()
948 trim_marked(tree); in audit_tag_tree()
951 put_tree(tree); in audit_tag_tree()