shit on top for debugging From: Eric Paris --- fs/notify/access.c | 10 +++++++ fs/notify/dnotify/dnotify.c | 6 ++++ fs/notify/fanotify/af_fanotify.c | 4 +++ fs/notify/fsnotify.c | 4 ++- fs/notify/group.c | 26 +++++++++++++++++- fs/notify/inode_mark.c | 7 +++++ fs/notify/inotify/inotify_fsnotify.c | 4 +++ fs/notify/inotify/inotify_user.c | 12 +++++++++ fs/notify/notification.c | 4 +++ kernel/audit/audit_tree.c | 48 +++++++++++++++++++++++++++++++++- kernel/audit/audit_watch.c | 5 ++++ 11 files changed, 126 insertions(+), 4 deletions(-) diff --git a/fs/notify/access.c b/fs/notify/access.c index 8177703..9971f88 100644 --- a/fs/notify/access.c +++ b/fs/notify/access.c @@ -33,6 +33,8 @@ int fsnotify_add_event_to_access(struct fsnotify_group *group, struct fsnotify_e { struct fsnotify_event_holder *holder; + printk(KERN_CRIT "%s: group=%p event=%p cookie=%lu\n", __func__, group, event, event->cookie); + if (list_empty(&event->holder.event_list)) holder = (struct fsnotify_event_holder *)event; else @@ -56,11 +58,14 @@ int fsnotify_get_response_from_access(struct fsnotify_group *group, struct fsnot { int ret; + printk(KERN_CRIT "%s: group=%p event=%p cookie=%lu\n", __func__, group, event, event->cookie); + restart: ret = wait_event_interruptible_timeout(group->access_waitq, event->response, msecs_to_jiffies(5000)); + printk(KERN_CRIT"%s: group=%p event=%p cookie=%lu ret=%d\n", __func__, group, event, event->cookie, ret); /* Timeout or signal? */ if (ret <= 0) { struct fsnotify_event_holder *holder; @@ -68,6 +73,7 @@ restart: /* pull the event off the access_list */ mutex_lock(&group->access_mutex); list_for_each_entry(holder, &group->access_list, event_list) { + printk(KERN_CRIT"%s: group=%p event=%p cookie=%lu holder=%p holder->event=%p\n", __func__, group, event, event->cookie, holder, holder->event); if (holder->event != event) continue; @@ -117,6 +123,7 @@ int fsnotify_process_access_response(struct fsnotify_group *group, unsigned long struct fsnotify_event *event = NULL; struct fsnotify_event_holder *holder; + printk(KERN_CRIT "%s: group=%p cookie=%lu response=%u\n", __func__, group, cookie, response); /* * make sure the response is valid, if invalid we do nothing and either * userspace can send a valid responce or we will clean it up after the @@ -127,6 +134,7 @@ int fsnotify_process_access_response(struct fsnotify_group *group, unsigned long mutex_lock(&group->access_mutex); list_for_each_entry(holder, &group->access_list, event_list) { + printk(KERN_CRIT "%s: group=%p cookie=%lu response=%u holder=%p holde->event=%p holder->event->cookie=%lu\n", __func__, group, cookie, response, holder, holder->event, holder->event->cookie); if (holder->event->cookie != cookie) continue; @@ -168,6 +176,8 @@ void fsnotify_flush_access(struct fsnotify_group *group) struct fsnotify_event *event = NULL; struct fsnotify_event_holder *holder; + printk(KERN_CRIT "%s: group=%p\n", __func__, group); + mutex_lock(&group->access_mutex); list_for_each_entry(holder, &group->access_list, event_list) { event = holder->event; diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 9f9a8c6..9089010 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c @@ -59,6 +59,8 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark_entry *entry) struct dnotify_mark_entry, fsn_entry); + printk(KERN_CRIT "%s: inode=%p\n", __func__, entry->inode); + assert_spin_locked(&entry->lock); old_mask = entry->mask; @@ -212,6 +214,8 @@ void dnotify_flush(struct file *filp, fl_owner_t id) return; dnentry = container_of(entry, struct dnotify_mark_entry, fsn_entry); + printk(KERN_CRIT "%s: found entry=%p entry->group=%p\n", __func__, entry, entry->group); + mutex_lock(&dnotify_mark_mutex); spin_lock(&entry->lock); @@ -319,6 +323,8 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) goto out_err; } + printk(KERN_CRIT "%s: fd=%d filp=%p arg=%lx\n", __func__, fd, filp, arg); + /* a 0 mask means we are explicitly removing the watch */ if ((arg & ~DN_MULTISHOT) == 0) { dnotify_flush(filp, id); diff --git a/fs/notify/fanotify/af_fanotify.c b/fs/notify/fanotify/af_fanotify.c index 05eafb9..27ef10d 100644 --- a/fs/notify/fanotify/af_fanotify.c +++ b/fs/notify/fanotify/af_fanotify.c @@ -181,6 +181,8 @@ int fanotify_create_event_fd(struct fsnotify_group *group, struct fanotify_event memset(data, 0, sizeof(struct fanotify_event_metadata)); + printk(KERN_CRIT "%s: group=%p\n", __func__, group); + while (1) { prepare_to_wait(&group->notification_waitq, &wait, TASK_INTERRUPTIBLE); @@ -212,6 +214,8 @@ int fanotify_create_event_fd(struct fsnotify_group *group, struct fanotify_event event = fsnotify_remove_notify_event(group); mutex_unlock(&group->notification_mutex); + printk(KERN_CRIT "%s: group=%p event=%p\n", __func__, group, event); + BUG_ON(!event); client_fd = get_unused_fd(); diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index a68d2f5..b95c56e 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -91,8 +91,9 @@ void __fsnotify_parent(struct dentry *dentry, __u32 mask) parent = dentry->d_parent; p_inode = parent->d_inode; - if (fsnotify_inode_watches_children(p_inode)) { + if (likely(fsnotify_inode_watches_children(p_inode))) { if (p_inode->i_fsnotify_mask & mask) { + printk(KERN_CRIT "%s: dentry=%p mask=%x parent=%p parent->inode=%p p_inode->i_fsnotify_mask=%x\n", __func__, dentry, mask, parent, p_inode, p_inode->i_fsnotify_mask); dget(parent); send = true; } @@ -158,6 +159,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const c if (mask & group->mask) { if (!group->ops->should_send_event(group, to_tell, mask)) continue; + printk(KERN_CRIT "%s: to_tell=%p data=%p data_is=%d mask=%x fsnotify_mask=%x\n", __func__, to_tell, data, data_is, mask, fsnotify_mask); if (!event) { event = fsnotify_create_event(to_tell, mask, data, data_is, file_name, cookie); /* shit, we OOM'd and now we can't tell, maybe diff --git a/fs/notify/group.c b/fs/notify/group.c index fcda327..91285e7 100644 --- a/fs/notify/group.c +++ b/fs/notify/group.c @@ -47,11 +47,17 @@ void fsnotify_recalc_global_mask(void) __u32 mask = 0; int idx; + printk(KERN_CRIT "%s: starting fsnotify_mask=%x\n", __func__, fsnotify_mask); + idx = srcu_read_lock(&fsnotify_grp_srcu); - list_for_each_entry_rcu(group, &fsnotify_groups, group_list) + list_for_each_entry_rcu(group, &fsnotify_groups, group_list) { + printk(KERN_CRIT "%s: group=%p group->mask=%x\n", __func__, group, group->mask); mask |= group->mask; + } srcu_read_unlock(&fsnotify_grp_srcu, idx); fsnotify_mask = mask; + + printk(KERN_CRIT "%s: ending fsnotify_mask=%x\n", __func__, fsnotify_mask); } /* @@ -67,12 +73,19 @@ void fsnotify_recalc_group_mask(struct fsnotify_group *group) struct fsnotify_mark_entry *entry; spin_lock(&group->mark_lock); - list_for_each_entry(entry, &group->mark_entries, g_list) + + printk(KERN_CRIT "%s: group=%p starting group->mask=%x\n", __func__, group, group->mask); + + list_for_each_entry(entry, &group->mark_entries, g_list) { + printk(KERN_CRIT "%s: entry=%p entry->mask=%x\n", __func__, entry, entry->mask); mask |= entry->mask; + } spin_unlock(&group->mark_lock); group->mask = mask; + printk(KERN_CRIT "%s: group=%p finishing group->mask=%x\n", __func__, group, group->mask); + if (old_mask != mask) fsnotify_recalc_global_mask(); } @@ -108,6 +121,8 @@ static void fsnotify_add_group(struct fsnotify_group *group) static void fsnotify_get_group(struct fsnotify_group *group) { atomic_inc(&group->refcnt); + + printk(KERN_CRIT "%s: group=%p refcnt=%d\n", __func__, group, atomic_read(&group->refcnt)); } /* @@ -115,6 +130,8 @@ static void fsnotify_get_group(struct fsnotify_group *group) */ void fsnotify_final_destroy_group(struct fsnotify_group *group) { + printk(KERN_CRIT "%s: group=%p refcnt=%d\n", __func__, group, atomic_read(&group->num_marks)); + /* clear the notification queue of all events */ fsnotify_flush_notify(group); @@ -137,6 +154,8 @@ void fsnotify_final_destroy_group(struct fsnotify_group *group) */ static void fsnotify_destroy_group(struct fsnotify_group *group) { + printk(KERN_CRIT "%s: group=%p refcnt=%d\n", __func__, group, atomic_read(&group->refcnt)); + /* clear all inode mark entries for this group */ fsnotify_clear_marks_by_group(group); @@ -176,6 +195,7 @@ void fsnotify_evict_group(struct fsnotify_group *group) */ void fsnotify_put_group(struct fsnotify_group *group) { + printk(KERN_CRIT "%s: group=%p refcnt=%d\n", __func__, group, atomic_read(&group->refcnt)); if (!atomic_dec_and_mutex_lock(&group->refcnt, &fsnotify_grp_mutex)) return; @@ -283,5 +303,7 @@ struct fsnotify_group *fsnotify_obtain_group(unsigned int priority, unsigned int if (mask) fsnotify_recalc_global_mask(); + printk(KERN_CRIT "%s: group=%p refcnt=%d\n", __func__, group, atomic_read(&group->refcnt)); + return group; } diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index dafff81..7169ed8 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c @@ -98,11 +98,13 @@ void fsnotify_get_mark(struct fsnotify_mark_entry *entry) { + printk(KERN_CRIT "%s: entry=%p refcnt BEFORE the get=%x\n", __func__, entry, atomic_read(&entry->refcnt)); atomic_inc(&entry->refcnt); } void fsnotify_put_mark(struct fsnotify_mark_entry *entry) { + printk(KERN_CRIT "%s: entry=%p refcnt BEFORE the put=%x\n", __func__, entry, atomic_read(&entry->refcnt)); if (atomic_dec_and_test(&entry->refcnt)) entry->free_mark(entry); } @@ -151,6 +153,8 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry) group = entry->group; inode = entry->inode; + printk(KERN_CRIT "%s: entry=%p entry->inode=%p entry->group=%p\n", __func__, entry, inode, group); + BUG_ON(group && !inode); BUG_ON(!group && inode); @@ -226,6 +230,7 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group) spin_lock(&group->mark_lock); list_for_each_entry_safe(entry, lentry, &group->mark_entries, g_list) { + printk(KERN_CRIT "%s: entry=%p entry->inode=%p entry->group=%p\n", __func__, entry, entry->inode, entry->group); list_add(&entry->free_g_list, &free_list); list_del_init(&entry->g_list); fsnotify_get_mark(entry); @@ -249,6 +254,7 @@ void fsnotify_clear_marks_by_inode(struct inode *inode) spin_lock(&inode->i_lock); hlist_for_each_entry_safe(entry, pos, n, &inode->i_fsnotify_mark_entries, i_list) { + printk(KERN_CRIT "%s: entry=%p entry->inode=%p entry->group=%p\n", __func__, entry, entry->inode, entry->group); list_add(&entry->free_i_list, &free_list); hlist_del_init(&entry->i_list); fsnotify_get_mark(entry); @@ -360,6 +366,7 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry, __fsnotify_update_child_dentry_flags(inode); } + printk(KERN_CRIT "%s: ret=%d group=%p inode=%p entry=%p entry->mask=%x\n", __func__, ret, group, inode, entry, entry->mask); return ret; } diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index 160da54..c424f87 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -40,6 +40,8 @@ static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_ev struct fsnotify_event_private_data *fsn_event_priv; int wd, ret; + printk(KERN_CRIT "%s: group=%p event=%p\n", __func__, group, event); + to_tell = event->to_tell; spin_lock(&to_tell->i_lock); @@ -82,6 +84,8 @@ static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_ev static void inotify_freeing_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group) { inotify_destroy_mark_entry(entry, group); + + printk(KERN_CRIT "%s: entry=%p\n", __func__, entry); } static bool inotify_should_send_event(struct fsnotify_group *group, struct inode *inode, __u32 mask) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 02447ae..a494d8e 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -232,6 +232,9 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, event_size += name_len; } + printk(KERN_CRIT "%s: event->wd=%d event->mask=%x event->cookie=%d event->len=%d event->file_name=%s\n", + __func__, inotify_event.wd, inotify_event.mask, inotify_event.cookie, inotify_event.len, event->file_name); + return event_size; } @@ -283,6 +286,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf, finish_wait(&group->notification_waitq, &wait); if (start != buf && ret != -EFAULT) ret = buf - start; + return ret; } @@ -352,6 +356,10 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns { int error; + char *tmp = getname(dirname); + printk(KERN_CRIT "%s: pathname=%s\n", __func__, tmp); + putname(tmp); + error = user_path_at(AT_FDCWD, dirname, flags, path); if (error) return error; @@ -384,6 +392,8 @@ void inotify_destroy_mark_entry(struct fsnotify_mark_entry *entry, struct fsnoti struct fsnotify_group *egroup; struct idr *idr; + printk(KERN_CRIT "%s: entry=%p refct=%d\n", __func__, entry, atomic_read(&entry->refcnt)); + spin_lock(&entry->lock); egroup = entry->group; @@ -430,6 +440,8 @@ static void inotify_free_mark(struct fsnotify_mark_entry *entry) { struct inotify_inode_mark_entry *ientry = (struct inotify_inode_mark_entry *)entry; + printk(KERN_CRIT "%s: entry=%p\n", __func__, entry); + kmem_cache_free(inotify_inode_mark_cachep, ientry); } diff --git a/fs/notify/notification.c b/fs/notify/notification.c index e2ced67..1e2b178 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -166,6 +166,8 @@ int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_even struct fsnotify_event_holder *last_holder; struct fsnotify_event *last_event; + printk(KERN_CRIT "%s: group=%p event=%p event->cookie=%lu priv=%p\n", __func__, group, event, event->cookie, priv); + /* easy to tell if priv was attached to the event */ INIT_LIST_HEAD(&priv->event_list); @@ -406,6 +408,8 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, event->cookie = 0; event->mask = mask; + printk(KERN_CRIT "%s: event=%p event->to_tell=%p event->data=%p event->data_type=%d event->file=%s\n", __func__, event, event->to_tell, event->inode, event->data_type, event->file_name); + return event; } diff --git a/kernel/audit/audit_tree.c b/kernel/audit/audit_tree.c index f132bf1..d253ad5 100644 --- a/kernel/audit/audit_tree.c +++ b/kernel/audit/audit_tree.c @@ -72,6 +72,7 @@ static struct audit_tree *alloc_tree(const char *s) { struct audit_tree *tree; + printk(KERN_CRIT "%s: s=%s\n", __func__, s); tree = kmalloc(sizeof(struct audit_tree) + strlen(s) + 1, GFP_KERNEL); if (tree) { atomic_set(&tree->count, 1); @@ -88,6 +89,7 @@ static struct audit_tree *alloc_tree(const char *s) static inline void get_tree(struct audit_tree *tree) { + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); atomic_inc(&tree->count); } @@ -95,10 +97,12 @@ static void __put_tree(struct rcu_head *rcu) { struct audit_tree *tree = container_of(rcu, struct audit_tree, head); kfree(tree); + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); } static inline void put_tree(struct audit_tree *tree) { + printk(KERN_CRIT "%s: tree=%p count=%d\n", __func__, tree, atomic_read(&tree->count)); if (atomic_dec_and_test(&tree->count)) call_rcu(&tree->head, __put_tree); } @@ -106,6 +110,7 @@ static inline void put_tree(struct audit_tree *tree) /* to avoid bringing the entire thing in audit.h */ const char *audit_tree_path(struct audit_tree *tree) { + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); return tree->pathname; } @@ -113,6 +118,7 @@ static void free_chunk(struct audit_chunk *chunk) { int i; + printk(KERN_CRIT "%s: chunk=%p\n", __func__, chunk); for (i = 0; i < chunk->count; i++) { if (chunk->owners[i].owner) put_tree(chunk->owners[i].owner); @@ -122,6 +128,7 @@ static void free_chunk(struct audit_chunk *chunk) void audit_put_chunk(struct audit_chunk *chunk) { + printk(KERN_CRIT "%s: chunk=%p chunk->refs=%ld\n", __func__, chunk, atomic_read(&chunk->refs)); if (atomic_long_dec_and_test(&chunk->refs)) free_chunk(chunk); } @@ -129,12 +136,14 @@ void audit_put_chunk(struct audit_chunk *chunk) static void __put_chunk(struct rcu_head *rcu) { struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head); + printk(KERN_CRIT "%s: rcu=%p chunk=%p\n", __func__, rcu, chunk); audit_put_chunk(chunk); } static void audit_tree_destroy_watch(struct fsnotify_mark_entry *entry) { struct audit_chunk *chunk = container_of(entry, struct audit_chunk, mark); + printk(KERN_CRIT "%s: entry=%p chunk=%p\n", __func__, entry, chunk); call_rcu(&chunk->head, __put_chunk); } @@ -144,6 +153,7 @@ static struct audit_chunk *alloc_chunk(int count) size_t size; int i; + printk(KERN_CRIT "%s: count=%d\n", __func__, count); size = offsetof(struct audit_chunk, owners) + count * sizeof(struct node); chunk = kzalloc(size, GFP_KERNEL); if (!chunk) @@ -177,6 +187,7 @@ static void insert_hash(struct audit_chunk *chunk) struct fsnotify_mark_entry *entry = &chunk->mark; struct list_head *list; + printk(KERN_CRIT "%s: here with entry->inode=%p\n", __func__, entry->inode); if (!entry->inode) return; list = chunk_hash(entry->inode); @@ -189,7 +200,9 @@ struct audit_chunk *audit_tree_lookup(const struct inode *inode) struct list_head *list = chunk_hash(inode); struct audit_chunk *p; + printk(KERN_CRIT "%s: inode=%p\n", __func__, inode); list_for_each_entry_rcu(p, list, hash) { + printk(KERN_CRIT "%s: here with inode=%p list=%p chunk=%p inode=%p\n", __func__, inode, list, p, inode); /* mark.inode may have gone NULL, but who cares? */ if (p->mark.inode == inode) { atomic_long_inc(&p->refs); @@ -202,6 +215,7 @@ struct audit_chunk *audit_tree_lookup(const struct inode *inode) int audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) { int n; + printk(KERN_CRIT "%s: chunk=%p tree=%p\n", __func__, chunk, tree); for (n = 0; n < chunk->count; n++) if (chunk->owners[n].owner == tree) return 1; @@ -213,6 +227,7 @@ int audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) static struct audit_chunk *find_chunk(struct node *p) { int index = p->index & ~(1U<<31); + printk(KERN_CRIT "%s: node=%p index=%d\n", __func__, p, index); p -= index; return container_of(p, struct audit_chunk, owners[0]); } @@ -231,6 +246,9 @@ static void untag_chunk(struct node *p) spin_unlock(&hash_lock); spin_lock(&entry->lock); + + printk(KERN_CRIT "%s: node=%p chunk=%p entry=%p chunk->dead=%d entry->inode=%p\n", __func__, p, chunk, entry, chunk->dead, entry->inode); + if (chunk->dead || !entry->inode) { spin_unlock(&entry->lock); goto out; @@ -316,6 +334,9 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) { struct fsnotify_mark_entry *entry; struct audit_chunk *chunk = alloc_chunk(1); + + printk(KERN_CRIT "%s: inode=%p tree=%p\n", __func__, inode, tree); + if (!chunk) return -ENOMEM; @@ -358,6 +379,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) struct node *p; int n; + printk(KERN_CRIT "%s: inode=%p tree=%p\n", __func__, inode, tree); + spin_lock(&inode->i_lock); old_entry = fsnotify_find_mark_entry(audit_tree_group, inode); spin_unlock(&inode->i_lock); @@ -452,6 +475,8 @@ static void kill_rules(struct audit_tree *tree) struct audit_entry *entry; struct audit_buffer *ab; + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); + list_for_each_entry_safe(rule, next, &tree->rules, rlist) { entry = container_of(rule, struct audit_entry, rule); @@ -481,6 +506,8 @@ static void kill_rules(struct audit_tree *tree) */ static void prune_one(struct audit_tree *victim) { + printk(KERN_CRIT "%s: victim=%p\n", __func__, victim); + spin_lock(&hash_lock); while (!list_empty(&victim->chunks)) { struct node *p; @@ -498,6 +525,9 @@ static void prune_one(struct audit_tree *victim) static void trim_marked(struct audit_tree *tree) { struct list_head *p, *q; + + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); + spin_lock(&hash_lock); if (tree->goner) { spin_unlock(&hash_lock); @@ -542,6 +572,9 @@ int audit_remove_tree_rule(struct audit_krule *rule) { struct audit_tree *tree; tree = rule->tree; + + printk(KERN_CRIT "%s: rule=%p tree=%p\n", __func__, rule, tree); + if (tree) { spin_lock(&hash_lock); list_del_init(&rule->rlist); @@ -566,6 +599,8 @@ void audit_trim_trees(void) { struct list_head cursor; + printk(KERN_CRIT "%s: nothing else to say\n", __func__); + mutex_lock(&audit_filter_mutex); list_add(&cursor, &tree_list); while (cursor.next != &tree_list) { @@ -621,6 +656,7 @@ skip_it: static int is_under(struct vfsmount *mnt, struct dentry *dentry, struct path *path) { + printk(KERN_CRIT "%s: mnt=%p dentry=%p path=%p\n", __func__, mnt, dentry, path); if (mnt != path->mnt) { for (;;) { if (mnt->mnt_parent == mnt) @@ -636,7 +672,7 @@ static int is_under(struct vfsmount *mnt, struct dentry *dentry, int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op) { - + printk(KERN_CRIT "%s: rule=%p pathname=%s op=%d\n", __func__, rule, pathname, op); if (pathname[0] != '/' || rule->listnr != AUDIT_FILTER_EXIT || op != Audit_equal || @@ -650,6 +686,7 @@ int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op) void audit_put_tree(struct audit_tree *tree) { + printk(KERN_CRIT "%s: tree=%p\n", __func__, tree); put_tree(tree); } @@ -662,6 +699,7 @@ int audit_add_tree_rule(struct audit_krule *rule) struct list_head list; int err; + printk(KERN_CRIT "%s: rule=%p seed=%p\n", __func__, rule, seed); list_for_each_entry(tree, &tree_list, list) { if (!strcmp(seed->pathname, tree->pathname)) { put_tree(seed); @@ -736,6 +774,8 @@ int audit_tag_tree(char *old, char *new) struct dentry *dentry; int err; + printk(KERN_CRIT "%s: old=%s new=%s\n", __func__, old, new); + err = kern_path(new, 0, &path); if (err) return err; @@ -847,6 +887,7 @@ int audit_tag_tree(char *old, char *new) */ void audit_prune_trees(void) { + printk(KERN_CRIT "%s: not much else to say\n", __func__); mutex_lock(&audit_filter_mutex); while (!list_empty(&prune_list)) { @@ -875,6 +916,8 @@ static void evict_chunk(struct audit_chunk *chunk) struct audit_tree *owner; int n; + printk(KERN_CRIT "%s: chunk=%p\n", __func__, chunk); + if (chunk->dead) return; @@ -902,6 +945,7 @@ static void evict_chunk(struct audit_chunk *chunk) static int audit_tree_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) { + printk(KERN_CRIT "%s: group=%p event=%p\n", __func__, group, event); BUG(); return -EOPNOTSUPP; } @@ -910,12 +954,14 @@ static void audit_tree_freeing_mark(struct fsnotify_mark_entry *entry, struct fs { struct audit_chunk *chunk = container_of(entry, struct audit_chunk, mark); + printk(KERN_CRIT "%s: entry=%p\n", __func__, entry); evict_chunk(chunk); fsnotify_put_mark(entry); } static bool audit_tree_send_event(struct fsnotify_group *group, struct inode *inode, __u32 mask) { + printk(KERN_CRIT "%s: group=%p inode=%p mask=%x\n", __func__, group, inode, mask); return 0; } diff --git a/kernel/audit/audit_watch.c b/kernel/audit/audit_watch.c index 86e6289..6685061 100644 --- a/kernel/audit/audit_watch.c +++ b/kernel/audit/audit_watch.c @@ -521,6 +521,8 @@ static int audit_watch_handle_event(struct fsnotify_group *group, struct fsnotif u32 mask = event->mask; const char *dname = event->file_name; + printk(KERN_CRIT "%s: mask=%x inode=%p to_tell=%p\n", __func__, mask, inode, to_tell); + BUG_ON(group != audit_group); parent = audit_find_parent(to_tell); @@ -561,6 +563,7 @@ static void audit_watch_freeing_mark(struct fsnotify_mark_entry *entry, { struct audit_parent *parent; + printk(KERN_CRIT "%s: entry=%p\n", __func__, entry); parent = container_of(entry, struct audit_parent, mark); audit_remove_parent_watches(parent); /* WTF do I match? */ @@ -576,6 +579,8 @@ static bool audit_watch_should_send_event(struct fsnotify_group *group, struct i BUG_ON(!(group->mask & mask)); + printk(KERN_CRIT "%s: group=%p inode=%p mask=%x\n", __func__, group, inode, mask); + parent = audit_find_parent(inode); if (!parent) return 0;