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
/* 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)
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;
}
/* 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 */
{
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) {
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)
void install_all(void)
{
- struct pf_group *pfg;
- struct sspt_proc *proc;
struct task_struct *task;
int tmp_oops_in_progress;
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);
}
}
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);
#include <linux/types.h>
+struct dentry;
struct task_struct;
struct proc_filter {
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;
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;
}
#include <pf/pf_group.h>
-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 ||
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;
(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,
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;
#include "ip.h"
#include <linux/types.h>
+enum US_FLAGS;
struct vm_area_struct;
struct sspt_file {
spin_lock(&page->lock);
-splice_and_unlock:
list_splice(&ip_list_tmp, head);
spin_unlock(&page->lock);
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
* 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);