2 #include <linux/fsnotify_backend.h>
3 #include <linux/namei.h>
4 #include <linux/mount.h>
5 #include <linux/kthread.h>
13 struct audit_chunk
*root
;
14 struct list_head chunks
;
15 struct list_head rules
;
16 struct list_head list
;
17 struct list_head same_root
;
23 struct list_head hash
;
24 struct fsnotify_mark_entry mark
;
25 struct list_head trees
; /* with root here */
31 struct list_head list
;
32 struct audit_tree
*owner
;
33 unsigned index
; /* index; upper bit indicates 'will prune' */
37 static LIST_HEAD(tree_list
);
38 static LIST_HEAD(prune_list
);
41 * One struct chunk is attached to each inode of interest.
42 * We replace struct chunk on tagging/untagging.
43 * Rules have pointer to struct audit_tree.
44 * Rules have struct list_head rlist forming a list of rules over
46 * References to struct chunk are collected at audit_inode{,_child}()
47 * time and used in AUDIT_TREE rule matching.
48 * These references are dropped at the same time we are calling
49 * audit_free_names(), etc.
51 * Cyclic lists galore:
52 * tree.chunks anchors chunk.owners[].list hash_lock
53 * tree.rules anchors rule.rlist audit_filter_mutex
54 * chunk.trees anchors tree.same_root hash_lock
55 * chunk.hash is a hash with middle bits of watch.inode as
56 * a hash function. RCU, hash_lock
58 * tree is refcounted; one reference for "some rules on rules_list refer to
59 * it", one for each chunk with pointer to it.
61 * chunk is refcounted by embedded inotify_watch + .refs (non-zero refcount
62 * of watch contributes 1 to .refs).
64 * node.index allows to get from node.list to containing chunk.
65 * MSB of that sucker is stolen to mark taggings that we might have to
66 * revert - several operations have very unpleasant cleanup logics and
67 * that makes a difference. Some.
70 static struct fsnotify_group
*audit_tree_group
;
72 static struct audit_tree
*alloc_tree(const char *s
)
74 struct audit_tree
*tree
;
76 tree
= kmalloc(sizeof(struct audit_tree
) + strlen(s
) + 1, GFP_KERNEL
);
78 atomic_set(&tree
->count
, 1);
80 INIT_LIST_HEAD(&tree
->chunks
);
81 INIT_LIST_HEAD(&tree
->rules
);
82 INIT_LIST_HEAD(&tree
->list
);
83 INIT_LIST_HEAD(&tree
->same_root
);
85 strcpy(tree
->pathname
, s
);
90 static inline void get_tree(struct audit_tree
*tree
)
92 atomic_inc(&tree
->count
);
95 static void __put_tree(struct rcu_head
*rcu
)
97 struct audit_tree
*tree
= container_of(rcu
, struct audit_tree
, head
);
101 static inline void put_tree(struct audit_tree
*tree
)
103 if (atomic_dec_and_test(&tree
->count
))
104 call_rcu(&tree
->head
, __put_tree
);
107 /* to avoid bringing the entire thing in audit.h */
108 const char *audit_tree_path(struct audit_tree
*tree
)
110 return tree
->pathname
;
113 static void free_chunk(struct audit_chunk
*chunk
)
117 for (i
= 0; i
< chunk
->count
; i
++) {
118 if (chunk
->owners
[i
].owner
)
119 put_tree(chunk
->owners
[i
].owner
);
124 void audit_put_chunk(struct audit_chunk
*chunk
)
126 if (atomic_long_dec_and_test(&chunk
->refs
))
130 static void __put_chunk(struct rcu_head
*rcu
)
132 struct audit_chunk
*chunk
= container_of(rcu
, struct audit_chunk
, head
);
133 audit_put_chunk(chunk
);
136 static void audit_tree_destroy_watch(struct fsnotify_mark_entry
*entry
)
138 struct audit_chunk
*chunk
= container_of(entry
, struct audit_chunk
, mark
);
139 call_rcu(&chunk
->head
, __put_chunk
);
142 static struct audit_chunk
*alloc_chunk(int count
)
144 struct audit_chunk
*chunk
;
148 size
= offsetof(struct audit_chunk
, owners
) + count
* sizeof(struct node
);
149 chunk
= kzalloc(size
, GFP_KERNEL
);
153 INIT_LIST_HEAD(&chunk
->hash
);
154 INIT_LIST_HEAD(&chunk
->trees
);
155 chunk
->count
= count
;
156 atomic_long_set(&chunk
->refs
, 1);
157 for (i
= 0; i
< count
; i
++) {
158 INIT_LIST_HEAD(&chunk
->owners
[i
].list
);
159 chunk
->owners
[i
].index
= i
;
161 fsnotify_init_mark(&chunk
->mark
, audit_tree_destroy_watch
);
165 enum {HASH_SIZE
= 128};
166 static struct list_head chunk_hash_heads
[HASH_SIZE
];
167 static __cacheline_aligned_in_smp
DEFINE_SPINLOCK(hash_lock
);
169 static inline struct list_head
*chunk_hash(const struct inode
*inode
)
171 unsigned long n
= (unsigned long)inode
/ L1_CACHE_BYTES
;
172 return chunk_hash_heads
+ n
% HASH_SIZE
;
175 /* hash_lock & entry->lock is held by caller */
176 static void insert_hash(struct audit_chunk
*chunk
)
178 struct fsnotify_mark_entry
*entry
= &chunk
->mark
;
179 struct list_head
*list
;
183 list
= chunk_hash(entry
->inode
);
184 list_add_rcu(&chunk
->hash
, list
);
187 /* called under rcu_read_lock */
188 struct audit_chunk
*audit_tree_lookup(const struct inode
*inode
)
190 struct list_head
*list
= chunk_hash(inode
);
191 struct audit_chunk
*p
;
193 list_for_each_entry_rcu(p
, list
, hash
) {
194 /* mark.inode may have gone NULL, but who cares? */
195 if (p
->mark
.inode
== inode
) {
196 atomic_long_inc(&p
->refs
);
203 int audit_tree_match(struct audit_chunk
*chunk
, struct audit_tree
*tree
)
206 for (n
= 0; n
< chunk
->count
; n
++)
207 if (chunk
->owners
[n
].owner
== tree
)
212 /* tagging and untagging inodes with trees */
214 static struct audit_chunk
*find_chunk(struct node
*p
)
216 int index
= p
->index
& ~(1U<<31);
218 return container_of(p
, struct audit_chunk
, owners
[0]);
221 static void untag_chunk(struct node
*p
)
223 struct audit_chunk
*chunk
= find_chunk(p
);
224 struct fsnotify_mark_entry
*entry
= &chunk
->mark
;
225 struct audit_chunk
*new;
226 struct audit_tree
*owner
;
227 int size
= chunk
->count
- 1;
230 fsnotify_get_mark(entry
);
232 spin_unlock(&hash_lock
);
234 spin_lock(&entry
->lock
);
235 if (chunk
->dead
|| !entry
->inode
) {
236 spin_unlock(&entry
->lock
);
244 spin_lock(&hash_lock
);
245 list_del_init(&chunk
->trees
);
246 if (owner
->root
== chunk
)
248 list_del_init(&p
->list
);
249 list_del_rcu(&chunk
->hash
);
250 spin_unlock(&hash_lock
);
251 spin_unlock(&entry
->lock
);
252 fsnotify_destroy_mark_by_entry(entry
);
253 fsnotify_put_mark(entry
);
257 new = alloc_chunk(size
);
260 fsnotify_duplicate_mark(&new->mark
, entry
);
261 if (fsnotify_add_mark(&new->mark
, new->mark
.group
, new->mark
.inode
, 1)) {
267 spin_lock(&hash_lock
);
268 list_replace_init(&chunk
->trees
, &new->trees
);
269 if (owner
->root
== chunk
) {
270 list_del_init(&owner
->same_root
);
274 for (i
= j
= 0; i
< size
; i
++, j
++) {
275 struct audit_tree
*s
;
276 if (&chunk
->owners
[j
] == p
) {
277 list_del_init(&p
->list
);
281 s
= chunk
->owners
[j
].owner
;
282 new->owners
[i
].owner
= s
;
283 new->owners
[i
].index
= chunk
->owners
[j
].index
- j
+ i
;
284 if (!s
) /* result of earlier fallback */
287 list_replace_init(&chunk
->owners
[i
].list
, &new->owners
[j
].list
);
290 list_replace_rcu(&chunk
->hash
, &new->hash
);
291 list_for_each_entry(owner
, &new->trees
, same_root
)
293 spin_unlock(&hash_lock
);
294 spin_unlock(&entry
->lock
);
295 fsnotify_destroy_mark_by_entry(entry
);
296 fsnotify_put_mark(entry
);
300 // do the best we can
301 spin_lock(&hash_lock
);
302 if (owner
->root
== chunk
) {
303 list_del_init(&owner
->same_root
);
306 list_del_init(&p
->list
);
309 spin_unlock(&hash_lock
);
310 spin_unlock(&entry
->lock
);
312 fsnotify_put_mark(entry
);
313 spin_lock(&hash_lock
);
316 static int create_chunk(struct inode
*inode
, struct audit_tree
*tree
)
318 struct fsnotify_mark_entry
*entry
;
319 struct audit_chunk
*chunk
= alloc_chunk(1);
323 entry
= &chunk
->mark
;
324 if (fsnotify_add_mark(entry
, audit_tree_group
, inode
, 0)) {
329 spin_lock(&entry
->lock
);
330 spin_lock(&hash_lock
);
332 spin_unlock(&hash_lock
);
334 spin_unlock(&entry
->lock
);
335 fsnotify_destroy_mark_by_entry(entry
);
336 fsnotify_put_mark(entry
);
339 chunk
->owners
[0].index
= (1U << 31);
340 chunk
->owners
[0].owner
= tree
;
342 list_add(&chunk
->owners
[0].list
, &tree
->chunks
);
345 list_add(&tree
->same_root
, &chunk
->trees
);
348 spin_unlock(&hash_lock
);
349 spin_unlock(&entry
->lock
);
353 /* the first tagged inode becomes root of tree */
354 static int tag_chunk(struct inode
*inode
, struct audit_tree
*tree
)
356 struct fsnotify_mark_entry
*old_entry
, *chunk_entry
;
357 struct audit_tree
*owner
;
358 struct audit_chunk
*chunk
, *old
;
362 spin_lock(&inode
->i_lock
);
363 old_entry
= fsnotify_find_mark_entry(audit_tree_group
, inode
);
364 spin_unlock(&inode
->i_lock
);
366 return create_chunk(inode
, tree
);
368 old
= container_of(old_entry
, struct audit_chunk
, mark
);
370 /* are we already there? */
371 spin_lock(&hash_lock
);
372 for (n
= 0; n
< old
->count
; n
++) {
373 if (old
->owners
[n
].owner
== tree
) {
374 spin_unlock(&hash_lock
);
375 fsnotify_put_mark(old_entry
);
379 spin_unlock(&hash_lock
);
381 chunk
= alloc_chunk(old
->count
+ 1);
384 chunk_entry
= &chunk
->mark
;
386 spin_lock(&old_entry
->lock
);
387 if (!old_entry
->inode
) {
388 /* old_entry is being shot, lets just lie */
389 spin_unlock(&old_entry
->lock
);
390 fsnotify_put_mark(old_entry
);
395 fsnotify_duplicate_mark(chunk_entry
, old_entry
);
396 if (fsnotify_add_mark(chunk_entry
, chunk_entry
->group
, chunk_entry
->inode
, 1)) {
397 spin_unlock(&old_entry
->lock
);
399 fsnotify_put_mark(old_entry
);
403 /* even though we hold old_entry->lock, this is safe since chunk_entry->lock could NEVER have been grabbed before */
404 spin_lock(&chunk_entry
->lock
);
405 spin_lock(&hash_lock
);
407 /* we now hold old_entry->lock, chunk_entry->lock, and hash_lock */
409 spin_unlock(&hash_lock
);
411 spin_unlock(&chunk_entry
->lock
);
412 spin_unlock(&old_entry
->lock
);
414 fsnotify_destroy_mark_by_entry(chunk_entry
);
416 fsnotify_put_mark(chunk_entry
);
417 fsnotify_put_mark(old_entry
);
420 list_replace_init(&old
->trees
, &chunk
->trees
);
421 for (n
= 0, p
= chunk
->owners
; n
< old
->count
; n
++, p
++) {
422 struct audit_tree
*s
= old
->owners
[n
].owner
;
424 p
->index
= old
->owners
[n
].index
;
425 if (!s
) /* result of fallback in untag */
428 list_replace_init(&old
->owners
[n
].list
, &p
->list
);
430 p
->index
= (chunk
->count
- 1) | (1U<<31);
433 list_add(&p
->list
, &tree
->chunks
);
434 list_replace_rcu(&old
->hash
, &chunk
->hash
);
435 list_for_each_entry(owner
, &chunk
->trees
, same_root
)
440 list_add(&tree
->same_root
, &chunk
->trees
);
442 spin_unlock(&hash_lock
);
443 spin_unlock(&chunk_entry
->lock
);
444 spin_unlock(&old_entry
->lock
);
445 fsnotify_destroy_mark_by_entry(old_entry
);
446 fsnotify_put_mark(old_entry
);
450 static void kill_rules(struct audit_tree
*tree
)
452 struct audit_krule
*rule
, *next
;
453 struct audit_entry
*entry
;
454 struct audit_buffer
*ab
;
456 list_for_each_entry_safe(rule
, next
, &tree
->rules
, rlist
) {
457 entry
= container_of(rule
, struct audit_entry
, rule
);
459 list_del_init(&rule
->rlist
);
461 /* not a half-baked one */
462 ab
= audit_log_start(NULL
, GFP_KERNEL
, AUDIT_CONFIG_CHANGE
);
463 audit_log_format(ab
, "op=");
464 audit_log_string(ab
, "remove rule");
465 audit_log_format(ab
, " dir=");
466 audit_log_untrustedstring(ab
, rule
->tree
->pathname
);
467 audit_log_key(ab
, rule
->filterkey
);
468 audit_log_format(ab
, " list=%d res=1", rule
->listnr
);
471 list_del_rcu(&entry
->list
);
472 list_del(&entry
->rule
.list
);
473 call_rcu(&entry
->rcu
, audit_free_rule_rcu
);
479 * finish killing struct audit_tree
481 static void prune_one(struct audit_tree
*victim
)
483 spin_lock(&hash_lock
);
484 while (!list_empty(&victim
->chunks
)) {
487 p
= list_entry(victim
->chunks
.next
, struct node
, list
);
491 spin_unlock(&hash_lock
);
495 /* trim the uncommitted chunks from tree */
497 static void trim_marked(struct audit_tree
*tree
)
499 struct list_head
*p
, *q
;
500 spin_lock(&hash_lock
);
502 spin_unlock(&hash_lock
);
506 for (p
= tree
->chunks
.next
; p
!= &tree
->chunks
; p
= q
) {
507 struct node
*node
= list_entry(p
, struct node
, list
);
509 if (node
->index
& (1U<<31)) {
511 list_add(p
, &tree
->chunks
);
515 while (!list_empty(&tree
->chunks
)) {
518 node
= list_entry(tree
->chunks
.next
, struct node
, list
);
520 /* have we run out of marked? */
521 if (!(node
->index
& (1U<<31)))
526 if (!tree
->root
&& !tree
->goner
) {
528 spin_unlock(&hash_lock
);
529 mutex_lock(&audit_filter_mutex
);
531 list_del_init(&tree
->list
);
532 mutex_unlock(&audit_filter_mutex
);
535 spin_unlock(&hash_lock
);
539 static void audit_schedule_prune(void);
541 /* called with audit_filter_mutex */
542 int audit_remove_tree_rule(struct audit_krule
*rule
)
544 struct audit_tree
*tree
;
547 spin_lock(&hash_lock
);
548 list_del_init(&rule
->rlist
);
549 if (list_empty(&tree
->rules
) && !tree
->goner
) {
551 list_del_init(&tree
->same_root
);
553 list_move(&tree
->list
, &prune_list
);
555 spin_unlock(&hash_lock
);
556 audit_schedule_prune();
560 spin_unlock(&hash_lock
);
566 void audit_trim_trees(void)
568 struct list_head cursor
;
570 mutex_lock(&audit_filter_mutex
);
571 list_add(&cursor
, &tree_list
);
572 while (cursor
.next
!= &tree_list
) {
573 struct audit_tree
*tree
;
575 struct vfsmount
*root_mnt
;
577 struct list_head list
;
580 tree
= container_of(cursor
.next
, struct audit_tree
, list
);
583 list_add(&cursor
, &tree
->list
);
584 mutex_unlock(&audit_filter_mutex
);
586 err
= kern_path(tree
->pathname
, 0, &path
);
590 root_mnt
= collect_mounts(&path
);
595 list_add_tail(&list
, &root_mnt
->mnt_list
);
596 spin_lock(&hash_lock
);
597 list_for_each_entry(node
, &tree
->chunks
, list
) {
598 struct audit_chunk
*chunk
= find_chunk(node
);
599 /* this could be NULL if the watch is dieing else where... */
600 struct inode
*inode
= chunk
->mark
.inode
;
601 struct vfsmount
*mnt
;
602 node
->index
|= 1U<<31;
603 list_for_each_entry(mnt
, &list
, mnt_list
) {
604 if (mnt
->mnt_root
->d_inode
== inode
) {
605 node
->index
&= ~(1U<<31);
610 spin_unlock(&hash_lock
);
613 list_del_init(&list
);
614 drop_collected_mounts(root_mnt
);
616 mutex_lock(&audit_filter_mutex
);
619 mutex_unlock(&audit_filter_mutex
);
622 static int is_under(struct vfsmount
*mnt
, struct dentry
*dentry
,
625 if (mnt
!= path
->mnt
) {
627 if (mnt
->mnt_parent
== mnt
)
629 if (mnt
->mnt_parent
== path
->mnt
)
631 mnt
= mnt
->mnt_parent
;
633 dentry
= mnt
->mnt_mountpoint
;
635 return is_subdir(dentry
, path
->dentry
);
638 int audit_make_tree(struct audit_krule
*rule
, char *pathname
, u32 op
)
641 if (pathname
[0] != '/' ||
642 rule
->listnr
!= AUDIT_FILTER_EXIT
||
644 rule
->inode_f
|| rule
->watch
|| rule
->tree
)
646 rule
->tree
= alloc_tree(pathname
);
652 void audit_put_tree(struct audit_tree
*tree
)
657 /* called with audit_filter_mutex */
658 int audit_add_tree_rule(struct audit_krule
*rule
)
660 struct audit_tree
*seed
= rule
->tree
, *tree
;
662 struct vfsmount
*mnt
, *p
;
663 struct list_head list
;
666 list_for_each_entry(tree
, &tree_list
, list
) {
667 if (!strcmp(seed
->pathname
, tree
->pathname
)) {
670 list_add(&rule
->rlist
, &tree
->rules
);
675 list_add(&tree
->list
, &tree_list
);
676 list_add(&rule
->rlist
, &tree
->rules
);
677 /* do not set rule->tree yet */
678 mutex_unlock(&audit_filter_mutex
);
680 err
= kern_path(tree
->pathname
, 0, &path
);
683 mnt
= collect_mounts(&path
);
689 list_add_tail(&list
, &mnt
->mnt_list
);
692 list_for_each_entry(p
, &list
, mnt_list
) {
693 err
= tag_chunk(p
->mnt_root
->d_inode
, tree
);
699 drop_collected_mounts(mnt
);
703 spin_lock(&hash_lock
);
704 list_for_each_entry(node
, &tree
->chunks
, list
)
705 node
->index
&= ~(1U<<31);
706 spin_unlock(&hash_lock
);
712 mutex_lock(&audit_filter_mutex
);
713 if (list_empty(&rule
->rlist
)) {
722 mutex_lock(&audit_filter_mutex
);
723 list_del_init(&tree
->list
);
724 list_del_init(&tree
->rules
);
729 int audit_tag_tree(char *old
, char *new)
731 struct list_head cursor
, barrier
;
734 struct vfsmount
*tagged
;
735 struct list_head list
;
736 struct vfsmount
*mnt
;
737 struct dentry
*dentry
;
740 err
= kern_path(new, 0, &path
);
743 tagged
= collect_mounts(&path
);
748 err
= kern_path(old
, 0, &path
);
750 drop_collected_mounts(tagged
);
753 mnt
= mntget(path
.mnt
);
754 dentry
= dget(path
.dentry
);
757 list_add_tail(&list
, &tagged
->mnt_list
);
759 mutex_lock(&audit_filter_mutex
);
760 list_add(&barrier
, &tree_list
);
761 list_add(&cursor
, &barrier
);
763 while (cursor
.next
!= &tree_list
) {
764 struct audit_tree
*tree
;
767 tree
= container_of(cursor
.next
, struct audit_tree
, list
);
770 list_add(&cursor
, &tree
->list
);
771 mutex_unlock(&audit_filter_mutex
);
773 err
= kern_path(tree
->pathname
, 0, &path
);
776 mutex_lock(&audit_filter_mutex
);
780 spin_lock(&vfsmount_lock
);
781 if (!is_under(mnt
, dentry
, &path
)) {
782 spin_unlock(&vfsmount_lock
);
785 mutex_lock(&audit_filter_mutex
);
788 spin_unlock(&vfsmount_lock
);
791 list_for_each_entry(p
, &list
, mnt_list
) {
792 failed
= tag_chunk(p
->mnt_root
->d_inode
, tree
);
799 mutex_lock(&audit_filter_mutex
);
803 mutex_lock(&audit_filter_mutex
);
804 spin_lock(&hash_lock
);
806 list_del(&tree
->list
);
807 list_add(&tree
->list
, &tree_list
);
809 spin_unlock(&hash_lock
);
813 while (barrier
.prev
!= &tree_list
) {
814 struct audit_tree
*tree
;
816 tree
= container_of(barrier
.prev
, struct audit_tree
, list
);
818 list_del(&tree
->list
);
819 list_add(&tree
->list
, &barrier
);
820 mutex_unlock(&audit_filter_mutex
);
824 spin_lock(&hash_lock
);
825 list_for_each_entry(node
, &tree
->chunks
, list
)
826 node
->index
&= ~(1U<<31);
827 spin_unlock(&hash_lock
);
833 mutex_lock(&audit_filter_mutex
);
838 mutex_unlock(&audit_filter_mutex
);
841 drop_collected_mounts(tagged
);
846 * That gets run when evict_chunk() ends up needing to kill audit_tree.
847 * Runs from a separate thread.
849 static int prune_tree_thread(void *unused
)
851 mutex_lock(&audit_cmd_mutex
);
852 mutex_lock(&audit_filter_mutex
);
854 while (!list_empty(&prune_list
)) {
855 struct audit_tree
*victim
;
857 victim
= list_entry(prune_list
.next
, struct audit_tree
, list
);
858 list_del_init(&victim
->list
);
860 mutex_unlock(&audit_filter_mutex
);
864 mutex_lock(&audit_filter_mutex
);
867 mutex_unlock(&audit_filter_mutex
);
868 mutex_unlock(&audit_cmd_mutex
);
872 static void audit_schedule_prune(void)
874 kthread_run(prune_tree_thread
, NULL
, "audit_prune_tree");
878 * ... and that one is done if evict_chunk() decides to delay until the end
879 * of syscall. Runs synchronously.
881 void audit_kill_trees(struct list_head
*list
)
883 mutex_lock(&audit_cmd_mutex
);
884 mutex_lock(&audit_filter_mutex
);
886 while (!list_empty(list
)) {
887 struct audit_tree
*victim
;
889 victim
= list_entry(list
->next
, struct audit_tree
, list
);
891 list_del_init(&victim
->list
);
893 mutex_unlock(&audit_filter_mutex
);
897 mutex_lock(&audit_filter_mutex
);
900 mutex_unlock(&audit_filter_mutex
);
901 mutex_unlock(&audit_cmd_mutex
);
905 * Here comes the stuff asynchronous to auditctl operations
908 /* inode->inotify_mutex is locked */
909 static void evict_chunk(struct audit_chunk
*chunk
)
911 struct audit_tree
*owner
;
912 struct list_head
*postponed
= audit_killed_trees();
920 mutex_lock(&audit_filter_mutex
);
921 spin_lock(&hash_lock
);
922 while (!list_empty(&chunk
->trees
)) {
923 owner
= list_entry(chunk
->trees
.next
,
924 struct audit_tree
, same_root
);
927 list_del_init(&owner
->same_root
);
928 spin_unlock(&hash_lock
);
931 list_move(&owner
->list
, &prune_list
);
934 list_move(&owner
->list
, postponed
);
936 spin_lock(&hash_lock
);
938 list_del_rcu(&chunk
->hash
);
939 for (n
= 0; n
< chunk
->count
; n
++)
940 list_del_init(&chunk
->owners
[n
].list
);
941 spin_unlock(&hash_lock
);
943 audit_schedule_prune();
944 mutex_unlock(&audit_filter_mutex
);
947 static int audit_tree_handle_event(struct fsnotify_group
*group
, struct fsnotify_event
*event
)
953 static void audit_tree_freeing_mark(struct fsnotify_mark_entry
*entry
, struct fsnotify_group
*group
)
955 struct audit_chunk
*chunk
= container_of(entry
, struct audit_chunk
, mark
);
958 fsnotify_put_mark(entry
);
961 static bool audit_tree_send_event(struct fsnotify_group
*group
, struct inode
*inode
,
962 __u32 mask
, void *data
, int data_type
)
967 static const struct fsnotify_ops audit_tree_ops
= {
968 .handle_event
= audit_tree_handle_event
,
969 .should_send_event
= audit_tree_send_event
,
970 .free_group_priv
= NULL
,
971 .free_event_priv
= NULL
,
972 .freeing_mark
= audit_tree_freeing_mark
,
975 static int __init
audit_tree_init(void)
979 audit_tree_group
= fsnotify_obtain_group(0, &audit_tree_ops
);
980 if (IS_ERR(audit_tree_group
))
981 audit_panic("cannot initialize inotify handle for rectree watches");
983 for (i
= 0; i
< HASH_SIZE
; i
++)
984 INIT_LIST_HEAD(&chunk_hash_heads
[i
]);
988 __initcall(audit_tree_init
);