5 * @file us_manager/sspt/sspt_proc.h
6 * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Copyright (C) Samsung Electronics, 2013
27 #include <linux/types.h>
28 #include <linux/mutex.h>
29 #include "sspt_file.h"
37 /** Flags for sspt_*_uninstall() */
39 US_UNREGS_PROBE, /**< probes remove and disarm */
40 US_DISARM, /**< probes disarm */
41 US_UNINSTALL /**< probes remove from list install */
46 * @breaf Image of process for specified process
49 struct list_head list; /**< For global process list */
52 struct list_head file_head; /**< For sspt_file */
54 pid_t tgid; /**< Thread group ID */
55 struct task_struct *leader; /**< Ptr to the task leader */
56 struct mm_struct *__mm;
57 struct task_struct *__task;
58 struct slot_manager *sm; /**< Ptr to the manager slot */
61 unsigned after_exec:1;
62 unsigned after_fork:1;
66 struct mutex mtx; /**< Mutex for filter list */
67 struct list_head head; /**< Filter head */
70 unsigned first_install:1; /**< Install flag */
71 struct sspt_feature *feature; /**< Ptr to the feature */
74 /* FIXME: for preload (remove those fields) */
75 unsigned long r_state_addr; /**< address of r_state */
76 void *private_data; /**< Process private data */
80 void *(*priv_create)(struct sspt_proc *);
81 void (*priv_destroy)(struct sspt_proc *, void *);
85 struct list_head *sspt_proc_list(void);
87 struct sspt_proc *sspt_proc_by_task(struct task_struct *task);
88 struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task);
89 struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task);
90 struct sspt_proc *sspt_proc_get(struct sspt_proc *proc);
91 void sspt_proc_put(struct sspt_proc *proc);
92 void sspt_proc_cleanup(struct sspt_proc *proc);
94 void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *),
96 void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data);
98 void sspt_proc_check_empty(void);
100 struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc,
101 struct dentry *dentry);
102 struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc,
103 struct dentry *dentry);
104 void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr);
105 void sspt_proc_install(struct sspt_proc *proc);
106 int sspt_proc_uninstall(struct sspt_proc *proc,
107 struct task_struct *task,
110 int sspt_proc_get_files_by_region(struct sspt_proc *proc,
111 struct list_head *head,
112 unsigned long start, size_t len);
113 void sspt_proc_insert_files(struct sspt_proc *proc, struct list_head *head);
115 void sspt_proc_read_lock(void);
116 void sspt_proc_read_unlock(void);
117 void sspt_proc_write_lock(void);
118 void sspt_proc_write_unlock(void);
120 void sspt_proc_add_filter(struct sspt_proc *proc, struct pf_group *pfg);
121 void sspt_proc_del_filter(struct sspt_proc *proc, struct pf_group *pfg);
122 void sspt_proc_del_all_filters(struct sspt_proc *proc);
123 bool sspt_proc_is_filter_new(struct sspt_proc *proc, struct pf_group *pfg);
125 void sspt_proc_on_each_filter(struct sspt_proc *proc,
126 void (*func)(struct sspt_filter *, void *),
129 void sspt_proc_on_each_ip(struct sspt_proc *proc,
130 void (*func)(struct sspt_ip *, void *), void *data);
132 bool sspt_proc_is_send_event(struct sspt_proc *proc);
134 int sspt_proc_cb_set(struct sspt_proc_cb *cb);
135 void sspt_proc_priv_create(struct sspt_proc *proc);
136 void sspt_proc_priv_destroy(struct sspt_proc *proc);
138 void sspt_reset_proc(struct task_struct *task);
139 void sspt_change_leader(struct task_struct *prev, struct task_struct *next);
140 int sspt_proc_init(void);
141 void sspt_proc_uninit(void);
144 #endif /* __SSPT_PROC__ */