struct pf_group {
struct list_head list;
struct img_proc *i_proc;
- struct proc_filter *filter;
+ struct proc_filter filter;
/* TODO: proc_list*/
struct list_head proc_list;
struct pl_struct *pls;
struct sspt_proc *proc;
- proc = sspt_proc_get_by_task_or_new(task, pfg->filter->priv);
+ proc = sspt_proc_get_by_task_or_new(task, pfg->filter.priv);
copy_proc_form_img_to_sspt(pfg->i_proc, proc);
pls = create_pl_struct(proc);
}
/* struct pl_struct */
-static struct pf_group *create_pfg(struct proc_filter *filter)
+static struct pf_group *create_pfg(void)
{
struct pf_group *pfg = kmalloc(sizeof(*pfg), GFP_KERNEL);
INIT_LIST_HEAD(&pfg->list);
- pfg->filter = filter;
+ memset(&pfg->filter, 0, sizeof(pfg->filter));
pfg->i_proc = create_img_proc();
INIT_LIST_HEAD(&pfg->proc_list);
struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_by_dentry(pfg->filter, dentry))
+ if (check_pf_by_dentry(&pfg->filter, dentry))
return pfg;
}
- filter = create_pf_by_dentry(dentry, priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_by_dentry(&pfg->filter, dentry, priv);
add_pfg_by_list(pfg);
struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_by_tgid(pfg->filter, tgid))
+ if (check_pf_by_tgid(&pfg->filter, tgid))
return pfg;
}
- filter = create_pf_by_tgid(tgid, priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_by_tgid(&pfg->filter, tgid, priv);
add_pfg_by_list(pfg);
struct pf_group *get_pf_group_dumb(void *priv)
{
struct pf_group *pfg;
- struct proc_filter *filter;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_pf_dumb(pfg->filter))
+ if (check_pf_dumb(&pfg->filter))
return pfg;
}
- filter = create_pf_dumb(priv);
- pfg = create_pfg(filter);
+ pfg = create_pfg();
+ set_pf_dumb(&pfg->filter, priv);
add_pfg_by_list(pfg);
struct pf_group *pfg;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_task_f(pfg->filter, task))
+ if (check_task_f(&pfg->filter, task))
return 1;
}
struct sspt_proc *proc = NULL;
list_for_each_entry(pfg, &pfg_list, list) {
- if (check_task_f(pfg->filter, task) == NULL)
+ if (check_task_f(&pfg->filter, task) == NULL)
continue;
proc = get_proc_by_pfg(pfg, task);
if (pfg_first) {
struct dentry *dentry;
- dentry = get_dentry_by_pf(pfg_first->filter);
+ dentry = get_dentry_by_pf(&pfg_first->filter);
if (dentry == NULL) {
dentry = task->mm->exe_file ?
task->mm->exe_file->f_dentry :
return task;
}
-static struct proc_filter *create_pf(void)
+void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry, void *priv)
{
- struct proc_filter *pf = kmalloc(sizeof(*pf), GFP_KERNEL);
-
- return pf;
-}
-
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv)
-{
- struct proc_filter *pf = create_pf();
-
pf->call = &call_by_dentry;
pf->data = (void *)dentry;
pf->priv = priv;
-
- return pf;
}
-struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv)
-{
- struct proc_filter *pf = create_pf();
+void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
+{
pf->call = &call_by_tgid;
pf->data = (void *)tgid;
pf->priv = priv;
-
- return pf;
}
-struct proc_filter *create_pf_dumb(void *priv)
+void set_pf_dumb(struct proc_filter *pf, void *priv)
{
- struct proc_filter *pf = create_pf();
-
pf->call = &call_dumb;
pf->data = NULL;
pf->priv = priv;
-
- return pf;
-}
-
-void free_pf(struct proc_filter *pf)
-{
- kfree(pf);
}
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry)
void *priv;
};
-#define check_task_f(filter, task) filter->call(filter, task)
+#define check_task_f(filter, task) (filter)->call(filter, task)
+
+void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry,
+ void *priv);
+void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv);
+void set_pf_dumb(struct proc_filter *pf, void *priv);
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv);
-struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv);
-struct proc_filter *create_pf_dumb(void *priv);
-void free_pf(struct proc_filter *pf);
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry);
int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid);