diff --git a/fs/namespace.c b/fs/namespace.c index 7b1ca9b..0445fc2 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -114,6 +114,9 @@ static int mnt_alloc_group_id(struct mount *mnt) if (!res) mnt_group_start = mnt->mnt_group_id + 1; + printk(KERN_INFO "gchen_tag: %p, mnt: %p, %s(): id: %d, res: %d, name: %s\n", + current, mnt, __FUNCTION__, mnt->mnt_group_id, res, mnt->mnt_devname); + return res; } @@ -123,6 +126,10 @@ static int mnt_alloc_group_id(struct mount *mnt) void mnt_release_group_id(struct mount *mnt) { int id = mnt->mnt_group_id; + + printk(KERN_INFO "gchen_tag: %p, mnt: %p, %s(): id: %d, name: %s\n", + current, mnt, __FUNCTION__, id, mnt->mnt_devname); + ida_remove(&mnt_group_ida, id); if (mnt_group_start > id) mnt_group_start = id; @@ -814,10 +821,13 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, mnt = alloc_vfsmnt(old->mnt_devname); if (!mnt) return ERR_PTR(-ENOMEM); - - if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE)) +#if 0 + if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE)) { + printk(KERN_INFO "gchen_tag: %p, %s() let mnt->mnt_group_id = 0\n", current, __FUNCTION__); mnt->mnt_group_id = 0; /* not a peer of original */ + } else +#endif mnt->mnt_group_id = old->mnt_group_id; if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c index 43c307d..23bbdfb 100644 --- a/kernel/audit_tree.c +++ b/kernel/audit_tree.c @@ -38,6 +38,8 @@ struct audit_chunk { static LIST_HEAD(tree_list); static LIST_HEAD(prune_list); +static volatile bool audit_test_count; + /* * One struct chunk is attached to each inode of interest. * We replace struct chunk on tagging/untagging. @@ -90,11 +92,13 @@ static struct audit_tree *alloc_tree(const char *s) static inline void get_tree(struct audit_tree *tree) { + printk(KERN_INFO "gchen_tag: %p, %s(): count before: %d\n", current, __FUNCTION__, atomic_read(&tree->count)); atomic_inc(&tree->count); } static inline void put_tree(struct audit_tree *tree) { + printk(KERN_INFO "gchen_tag: %p, %s(): count before: %d\n", current, __FUNCTION__, atomic_read(&tree->count)); if (atomic_dec_and_test(&tree->count)) kfree_rcu(tree, head); } @@ -474,7 +478,9 @@ static void kill_rules(struct audit_tree *tree) entry = container_of(rule, struct audit_entry, rule); list_del_init(&rule->rlist); + printk(KERN_INFO "gchen_tag: %p, %s(): list_del_init, rule: %p, tree: %p\n", current, __FUNCTION__, rule, rule->tree); if (rule->tree) { + printk(KERN_INFO "gchen_tag: %p, %s(): remove entry: %p\n", current, __FUNCTION__, entry); /* not a half-baked one */ audit_log_remove_rule(rule); rule->tree = NULL; @@ -657,6 +663,9 @@ int audit_add_tree_rule(struct audit_krule *rule) struct path path; struct vfsmount *mnt; int err; + long long i = 0; + + audit_test_count = false; rule->tree = NULL; list_for_each_entry(tree, &tree_list, list) { @@ -698,8 +707,20 @@ int audit_add_tree_rule(struct audit_krule *rule) goto Err; } + printk(KERN_INFO "gchen_tag: %p, %s(): begin waiting 100...., rule: %p\n", current, __FUNCTION__, rule); + while (!audit_test_count) { + schedule(); + if (i++ > 1000000*100) { + printk(KERN_INFO "gchen_tag: %p, %s(): i exceed.\n", current, __FUNCTION__); + break; + } + } + printk(KERN_INFO "gchen_tag: %p, %s(): end waiting, rule: %p\n", current, __FUNCTION__, rule); + + mutex_lock(&audit_filter_mutex); if (list_empty(&rule->rlist)) { + printk(KERN_INFO "gchen_tag: %p, %s(): list empty for rule->rlist and return fail: %p\n", current, __FUNCTION__, rule); put_tree(tree); return -ENOENT; } @@ -883,6 +904,8 @@ static void evict_chunk(struct audit_chunk *chunk) if (chunk->dead) return; + printk(KERN_INFO "gchen_tag: %p, %s(): enter function postponed: %p\n", current, __FUNCTION__, postponed); + chunk->dead = 1; mutex_lock(&audit_filter_mutex); spin_lock(&hash_lock); @@ -894,6 +917,7 @@ static void evict_chunk(struct audit_chunk *chunk) list_del_init(&owner->same_root); spin_unlock(&hash_lock); if (!postponed) { + printk(KERN_INFO "gchen_tag: %p, %s(): kill_rull postponed: %p\n", current, __FUNCTION__, postponed); kill_rules(owner); list_move(&owner->list, &prune_list); need_prune = 1; @@ -906,9 +930,14 @@ static void evict_chunk(struct audit_chunk *chunk) for (n = 0; n < chunk->count; n++) list_del_init(&chunk->owners[n].list); spin_unlock(&hash_lock); - if (need_prune) + if (need_prune) { + printk(KERN_INFO "gchen_tag: %p, %s(): audit_schedule_prune postponed: %p\n", current, __FUNCTION__, postponed); audit_schedule_prune(); + } mutex_unlock(&audit_filter_mutex); + + printk(KERN_INFO "gchen_tag: %p, %s(): set audit_test_count = true, postponed: %p\n", current, __FUNCTION__, postponed); + audit_test_count = true; } static int audit_tree_handle_event(struct fsnotify_group *group, diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 83a2970..a6ae516 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c @@ -72,6 +72,8 @@ static inline void audit_free_rule(struct audit_entry *e) int i; struct audit_krule *erule = &e->rule; + printk(KERN_INFO "gchen_tag: %p, %s(): remove entry: %p\n", current, __FUNCTION__, e); + /* some rules don't have associated watches */ if (erule->watch) audit_put_watch(erule->watch); diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 9845cb3..8e063b7 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2417,8 +2417,11 @@ void __audit_seccomp(unsigned long syscall, long signr, int code) struct list_head *audit_killed_trees(void) { + return NULL; +#if 0 struct audit_context *ctx = current->audit_context; if (likely(!ctx || !ctx->in_syscall)) return NULL; return &ctx->killed_trees; +#endif }