{
struct dentry *dentry;
+ dentry = dentry_by_path(app_info->exec_path);
+ if (dentry == NULL)
+ return -EINVAL;
+
switch (app_info->app_type) {
case AT_PID:
- *pfg = get_pf_group_by_tgid(app_info->tgid);
+ *pfg = get_pf_group_by_tgid(app_info->tgid, dentry);
break;
case AT_TIZEN_NATIVE_APP:
case AT_COMMON_EXEC:
- dentry = dentry_by_path(app_info->exec_path);
- if (dentry == NULL)
- return -EINVAL;
-
- *pfg = get_pf_group_by_dentry(dentry);
+ *pfg = get_pf_group_by_dentry(dentry, dentry);
break;
default:
printk("ERROR: app_type=%0x%x\n", app_info->app_type);
if (proc == NULL) {
struct pl_struct *pls;
- proc = sspt_proc_get_by_task_or_new(task);
+ 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);
list_del(&pfg->list);
}
-struct pf_group *get_pf_group_by_dentry(struct dentry *dentry)
+struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
{
struct pf_group *pfg;
struct proc_filter *filter;
return pfg;
}
- filter = create_pf_by_dentry(dentry);
+ filter = create_pf_by_dentry(dentry, priv);
pfg = create_pfg(filter);
add_pfg_by_list(pfg);
}
EXPORT_SYMBOL_GPL(get_pf_group_by_dentry);
-struct pf_group *get_pf_group_by_tgid(pid_t tgid)
+struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
{
struct pf_group *pfg;
struct proc_filter *filter;
return pfg;
}
- filter = create_pf_by_tgid(tgid);
+ filter = create_pf_by_tgid(tgid, priv);
pfg = create_pfg(filter);
add_pfg_by_list(pfg);
list_for_each_entry(pfg, &pfg_list, list) {
if (check_task_f(pfg->filter, task)) {
- proc = sspt_proc_get_by_task_or_new(task);
+ proc = sspt_proc_get_by_task_or_new(task,
+ pfg->filter->priv);
sspt_proc_install(proc);
}
}
struct dentry;
struct pf_group;
-struct pf_group *get_pf_group_by_dentry(struct dentry *dentry);
-struct pf_group *get_pf_group_by_tgid(pid_t tgid);
+struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv);
+struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv);
void put_pf_group(struct pf_group *pfg);
int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
return pf;
}
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry)
+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)
+struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv)
{
struct proc_filter *pf = create_pf();
pf->call = &call_by_tgid;
pf->data = (void *)tgid;
+ pf->priv = priv;
return pf;
}
struct task_struct *(*call)(struct proc_filter *self,
struct task_struct *task);
void *data;
+ void *priv;
};
#define check_task_f(filter, task) filter->call(filter, task)
-struct proc_filter *create_pf_by_dentry(struct dentry *dentry);
-struct proc_filter *create_pf_by_tgid(pid_t tgid);
+struct proc_filter *create_pf_by_dentry(struct dentry *dentry, void *priv);
+struct proc_filter *create_pf_by_tgid(pid_t tgid, void *priv);
void free_pf(struct proc_filter *pf);
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry);
int i, ret;
struct pf_group *pfg;
- pfg = get_pf_group_by_dentry(task_inst_info->m_f_dentry);
+ pfg = get_pf_group_by_dentry(task_inst_info->m_f_dentry,
+ task_inst_info->m_f_dentry);
for (i = 0; i < task_inst_info->libs_count; ++i) {
int k, j;
static LIST_HEAD(proc_probes_list);
-struct sspt_proc *sspt_proc_create(struct task_struct *task)
+struct sspt_proc *sspt_proc_create(struct task_struct *task, void *priv)
{
struct sspt_proc *proc = kmalloc(sizeof(*proc), GFP_ATOMIC);
list_add(&proc->list, &proc_probes_list);
}
- proc_info_msg(task);
+ proc_info_msg(task, priv);
return proc;
}
return NULL;
}
-struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task)
+struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
+ void *priv)
{
struct sspt_proc *proc = sspt_proc_get_by_task(task);
if (proc == NULL) {
- proc = sspt_proc_create(task);
+ proc = sspt_proc_create(task, priv);
}
return proc;
};
-struct sspt_proc *sspt_proc_create(struct task_struct *task);
+struct sspt_proc *sspt_proc_create(struct task_struct *task, void *priv);
void sspt_proc_free(struct sspt_proc *proc);
struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task);
-struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task);
+struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
+ void *priv);
void sspt_proc_free_all(void);
struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *dentry);
!(vma->vm_flags & (VM_READ | VM_MAYREAD)));
}
+static struct vm_area_struct *find_vma_by_dentry(struct mm_struct *mm,
+ struct dentry *dentry)
+{
+ struct vm_area_struct *vma;
+
+ down_write(&mm->mmap_sem);
+ for (vma = mm->mmap; vma; vma = vma->vm_next) {
+ if (check_vma(vma) && vma->vm_file &&
+ (vma->vm_file->f_dentry == dentry))
+ goto out;
+ }
+
+ vma = NULL;
+
+out:
+ up_write(&mm->mmap_sem);
+
+ return vma;
+}
+
static char *pack_proc_info_part(char *bin_path, struct mm_struct *mm)
{
struct proc_info_part *pip;
struct vm_area_struct *vma;
char *lib_obj, *end_path = NULL;
int lib_cnt = 0;
+ char bin_path_def[] = "";
- end_path = pack_path(bin_path, mm->exe_file);
+ memcpy(bin_path, bin_path_def, sizeof(bin_path_def));
+ end_path = bin_path + sizeof(bin_path_def);
pip = (struct proc_info_part *)end_path;
lib_obj = pip->libs;
return lib_obj;
}
-static char *pack_proc_info(char *payload, struct task_struct *task)
+static char *pack_proc_info(char *payload, struct task_struct *task,
+ void *priv)
{
struct proc_info *pi = (struct proc_info *)payload;
+ struct dentry *dentry_exec = (struct dentry *)priv;
+ struct vm_area_struct *vma = find_vma_by_dentry(task->mm, dentry_exec);
pi->pid = task->tgid;
/* FIXME: */
pi->start_time = timespec2time(&task->start_time);
- pi->low_addr = 2;
- pi->high_addr = 3;
- pi->app_type = 4;
- pi->bin_type = 5;
+ pi->low_addr = vma ? vma->vm_start : 0;
+ pi->high_addr = vma ? vma->vm_end : 0;
+ pi->app_type = 1; /* TODO: hardcode for Tizen*/
+ pi->bin_type = 0; /* TODO: determined in US */
return pack_proc_info_part(pi->bin_path, task->mm);
}
-int proc_info_msg(struct task_struct *task)
+int proc_info_msg(struct task_struct *task, void *priv)
{
char *buf, *payload, *buf_end;
buf = get_current_buf();
payload = pack_basic_msg_fmt(buf, MSG_PROC_INFO);
- buf_end = pack_proc_info(payload, task);
+ buf_end = pack_proc_info(payload, task, priv);
set_len_msg(buf, buf_end);
int init_msg(size_t buf_size);
void uninit_msg(void);
-int proc_info_msg(struct task_struct *task);
+int proc_info_msg(struct task_struct *task, void *priv);
int sample_msg(struct pt_regs *regs);
int entry_event(const char *fmt, struct pt_regs *regs,