From 2e7ff1e20d3d9804b89890b8e26d992c0294221f Mon Sep 17 00:00:00 2001 From: Anastasia Lyupa Date: Wed, 6 Nov 2013 12:25:02 +0400 Subject: [PATCH] [FIX] warnings in swap_us_manager build it with -Werror Change-Id: Ieb752474cf0cb56ebbba35c5fc38209d558ef257 Signed-off-by: Anastasia Lyupa --- build.sh | 2 +- us_manager/helper.c | 1 - us_manager/img/img_file.c | 2 +- us_manager/img/img_ip.c | 2 +- us_manager/pf/pf_group.c | 9 +++------ us_manager/pf/pf_group.h | 1 + us_manager/pf/proc_filters.h | 1 + us_manager/sspt/ip.c | 27 +++++++++++++++++---------- us_manager/sspt/sspt.h | 8 ++++---- us_manager/sspt/sspt_debug.h | 2 +- us_manager/sspt/sspt_file.c | 2 -- us_manager/sspt/sspt_file.h | 1 + us_manager/sspt/sspt_page.c | 1 - us_manager/us_slot_manager.c | 4 ++-- 14 files changed, 33 insertions(+), 30 deletions(-) diff --git a/build.sh b/build.sh index 0f876aa..12cdfad 100755 --- a/build.sh +++ b/build.sh @@ -72,7 +72,7 @@ make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${uprobe_dir us_manager_module_name=swap_us_manager.ko make CROSS_COMPILE=${cross_compile} ARCH=${arch} -C ${kernel_dir} M=${us_manager_dir} \ - extra_cflags="-I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${ksyms_dir}" \ + extra_cflags="-Werror -I${modules_dir} -I${us_manager_dir} -I${kprobe_dir} -I${kprobe_arch_dir} -I${uprobe_dir} -I${uprobe_arch_dir} -I${driver_dir} -I${ksyms_dir}" \ modules || exit 1 ks_features_module_name=swap_ks_features.ko diff --git a/us_manager/helper.c b/us_manager/helper.c index 10b963c..fb61bb3 100644 --- a/us_manager/helper.c +++ b/us_manager/helper.c @@ -136,7 +136,6 @@ static struct kretprobe cp_kretprobe = { /* Detects when target process removes IPs. */ static int mr_pre_handler(struct kprobe *p, struct pt_regs *regs) { - struct sspt_proc *proc = NULL; struct task_struct *task; #if defined(CONFIG_X86) diff --git a/us_manager/img/img_file.c b/us_manager/img/img_file.c index 4edf984..e4d05c6 100644 --- a/us_manager/img/img_file.c +++ b/us_manager/img/img_file.c @@ -90,7 +90,7 @@ int img_file_del_ip(struct img_file *file, unsigned long addr) ip = find_img_ip(file, addr); if (ip == NULL) { - printk("Warning: no ip found in img, addr = %p\n", addr); + printk("Warning: no ip found in img, addr = %lx\n", addr); return -EINVAL; } diff --git a/us_manager/img/img_ip.c b/us_manager/img/img_ip.c index 224627a..13258b0 100644 --- a/us_manager/img/img_ip.c +++ b/us_manager/img/img_ip.c @@ -52,6 +52,6 @@ void free_img_ip(struct img_ip *ip) /* debug */ void img_ip_print(struct img_ip *ip) { - printk("### addr=8%x, args=%s\n", ip->addr, ip->args); + printk("### addr=8%lx, args=%s\n", ip->addr, ip->args); } /* debug */ diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c index fe9e273..841116a 100644 --- a/us_manager/pf/pf_group.c +++ b/us_manager/pf/pf_group.c @@ -255,7 +255,7 @@ void uninstall_proc(struct sspt_proc *proc) { struct task_struct *task = proc->task; struct pf_group *pfg; - struct pls_struct *pls; + struct pl_struct *pls; int i; list_for_each_entry(pfg, &pfg_list, list) { @@ -284,7 +284,7 @@ void uninstall_proc(struct sspt_proc *proc) void call_mm_release(struct task_struct *task) { - struct sspt_struct *proc; + struct sspt_proc *proc; proc = sspt_proc_get_by_task(task); if (proc) @@ -298,8 +298,6 @@ void uninstall_page(unsigned long addr) void install_all(void) { - struct pf_group *pfg; - struct sspt_proc *proc; struct task_struct *task; int tmp_oops_in_progress; @@ -322,10 +320,9 @@ void install_all(void) static void clean_pfg(void) { struct pf_group *pfg, *n; - struct proc_filter *filter; list_for_each_entry_safe(pfg, n, &pfg_list, list) { - list_del(&pfg->list); + del_pfg_by_list(pfg); free_pfg(pfg); } } diff --git a/us_manager/pf/pf_group.h b/us_manager/pf/pf_group.h index 05f8fe1..377b59b 100644 --- a/us_manager/pf/pf_group.h +++ b/us_manager/pf/pf_group.h @@ -30,6 +30,7 @@ struct dentry; struct pf_group; +struct sspt_proc; 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); diff --git a/us_manager/pf/proc_filters.h b/us_manager/pf/proc_filters.h index 94673be..2857419 100644 --- a/us_manager/pf/proc_filters.h +++ b/us_manager/pf/proc_filters.h @@ -28,6 +28,7 @@ #include +struct dentry; struct task_struct; struct proc_filter { diff --git a/us_manager/sspt/ip.c b/us_manager/sspt/ip.c index 928fc06..89f5a59 100644 --- a/us_manager/sspt/ip.c +++ b/us_manager/sspt/ip.c @@ -50,7 +50,7 @@ static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) if (rp && get_quiet() == QT_OFF) { struct us_ip *ip = container_of(rp, struct us_ip, retprobe); unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr; - unsigned long ret_addr = ri->ret_addr; + unsigned long ret_addr = (unsigned long)ri->ret_addr; #if defined(CONFIG_ARM) addr = ip->offset & 0x01 ? addr | 0x01 : addr; @@ -64,18 +64,25 @@ static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs) struct us_ip *create_ip(unsigned long offset, const char *args) { - struct us_ip *ip = kmalloc(sizeof(*ip), GFP_ATOMIC); - memset(ip, 0, sizeof(*ip)); + size_t len = strlen(args) + 1; + struct us_ip *ip = kmalloc(sizeof(*ip) + len, GFP_ATOMIC); - INIT_LIST_HEAD(&ip->list); - ip->offset = offset; + if (ip != NULL) { + memset(ip, 0, sizeof(*ip)); - /* TODO: or copy args?! */ - ip->args = args; + INIT_LIST_HEAD(&ip->list); + ip->offset = offset; + ip->args = (char *)ip + sizeof(*ip); - /* retprobe */ - ip->retprobe.handler = ret_handler; - ip->retprobe.entry_handler = entry_handler; + /* copy args */ + memcpy(ip->args, args, len); + + /* retprobe */ + ip->retprobe.handler = ret_handler; + ip->retprobe.entry_handler = entry_handler; + } else { + printk("Cannot kmalloc in create_ip function!\n"); + } return ip; } diff --git a/us_manager/sspt/sspt.h b/us_manager/sspt/sspt.h index 7b527bc..7367f8a 100644 --- a/us_manager/sspt/sspt.h +++ b/us_manager/sspt/sspt.h @@ -37,7 +37,7 @@ #include -static int check_vma(struct vm_area_struct *vma) +static inline int check_vma(struct vm_area_struct *vma) { return vma->vm_file && !(vma->vm_pgoff != 0 || @@ -57,11 +57,11 @@ static inline int sspt_register_usprobe(struct us_ip *ip) if (ret) { struct sspt_file *file = ip->page->file; char *name = file->dentry->d_iname; - unsigned long addr =ip->retprobe.up.kp.addr; + unsigned long addr = (unsigned long)ip->retprobe.up.kp.addr; unsigned long offset = addr - file->vm_start; - printk("dbi_register_uretprobe() failure %d (%s:%x|%x)\n", - ret, name, offset, ip->retprobe.up.kp.opcode); + printk("dbi_register_uretprobe() failure %d (%s:%lx|%lx)\n", + ret, name, offset, (unsigned long)ip->retprobe.up.kp.opcode); } return ret; diff --git a/us_manager/sspt/sspt_debug.h b/us_manager/sspt/sspt_debug.h index e1832cf..5e5b8f3 100644 --- a/us_manager/sspt/sspt_debug.h +++ b/us_manager/sspt/sspt_debug.h @@ -39,7 +39,7 @@ static inline void print_retprobe(struct uretprobe *rp) (unsigned long)rp->handler); } -static inline print_ip(struct us_ip *ip, int i) +static inline void print_ip(struct us_ip *ip, int i) { printk("### addr[%2d]=%lx, R_addr=%lx\n", i, (unsigned long)ip->offset, diff --git a/us_manager/sspt/sspt_file.c b/us_manager/sspt/sspt_file.c index ffcab3d..a82e251 100644 --- a/us_manager/sspt/sspt_file.c +++ b/us_manager/sspt/sspt_file.c @@ -234,8 +234,6 @@ int sspt_file_uninstall(struct sspt_file *file, struct task_struct *task, enum U void sspt_file_set_mapping(struct sspt_file *file, struct vm_area_struct *vma) { - struct task_struct *task = file->proc->task; - file->vm_start = vma->vm_start; file->vm_end = vma->vm_end; diff --git a/us_manager/sspt/sspt_file.h b/us_manager/sspt/sspt_file.h index dbc1d08..2c19e1d 100644 --- a/us_manager/sspt/sspt_file.h +++ b/us_manager/sspt/sspt_file.h @@ -28,6 +28,7 @@ #include "ip.h" #include +enum US_FLAGS; struct vm_area_struct; struct sspt_file { diff --git a/us_manager/sspt/sspt_page.c b/us_manager/sspt/sspt_page.c index d90484d..6dc350f 100644 --- a/us_manager/sspt/sspt_page.c +++ b/us_manager/sspt/sspt_page.c @@ -172,7 +172,6 @@ int sspt_unregister_page(struct sspt_page *page, spin_lock(&page->lock); -splice_and_unlock: list_splice(&ip_list_tmp, head); spin_unlock(&page->lock); diff --git a/us_manager/us_slot_manager.c b/us_manager/us_slot_manager.c index c45b642..cd8ddfd 100644 --- a/us_manager/us_slot_manager.c +++ b/us_manager/us_slot_manager.c @@ -77,8 +77,6 @@ static void *sm_alloc_us(struct slot_manager *sm) static void sm_free_us(struct slot_manager *sm, void *ptr) { - struct task_struct *task = sm->data; - /* * E. G.: This code provides kernel dump because of rescheduling while atomic. * As workaround, this code was commented. In this case we will have memory leaks @@ -87,6 +85,8 @@ static void sm_free_us(struct slot_manager *sm, void *ptr) * for improving supportability and performance. */ #if 0 + struct task_struct *task = sm->data; + mm = get_task_mm(task); if (mm) { down_write(&mm->mmap_sem); -- 2.7.4