#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/uaccess.h>
+#include <linux/version.h>
#include <ksyms/ksyms.h>
#include <master/swap_initializer.h>
static const struct pipe_buf_operations swap_device_pipe_buf_ops = {
.can_merge = 0,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 0)
.map = generic_pipe_buf_map,
.unmap = generic_pipe_buf_unmap,
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 0) */
.confirm = generic_pipe_buf_confirm,
.release = swap_device_pipe_buf_release,
.steal = generic_pipe_buf_steal,
#include <linux/string.h>
#include <linux/slab.h>
+#include <linux/fs.h>
#include <linux/splice.h>
#include <linux/uaccess.h>
#include <linux/spinlock.h>
msg->len = size;
memcpy(msg->data, data, msg->len);
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 0)
ret = cn_netlink_send(msg, CN_DAEMON_GROUP, GFP_ATOMIC);
+#else /* LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 0) */
+ ret = cn_netlink_send(msg, 0, CN_DAEMON_GROUP, GFP_ATOMIC);
+#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 0) */
if (ret < 0)
goto fail_send;
kfree(msg);
#ifndef __US_INTERACTION_H__
#define __US_INTERACTION_H__
+#include <linux/version.h>
+
#ifdef CONFIG_CONNECTOR
int us_interaction_create(void);
file = fget(fd);
if (file) {
int magic = 0;
- if (file->f_dentry && file->f_dentry->d_sb)
- magic = file->f_dentry->d_sb->s_magic;
+ if (file->f_path.dentry && file->f_path.dentry->d_sb)
+ magic = file->f_path.dentry->d_sb->s_magic;
fput(file);
buf[ret >= buf_len ? buf_len - 1 : ret] = '\0';
- ret = strict_strtoul(buf, 0, &val);
+ ret = kstrtoul(buf, 0, &val);
if (ret)
return ret;
/* TODO FILTER vma */
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (vma->vm_file &&
- (vma->vm_file->f_dentry == dentry))
+ (vma->vm_file->f_path.dentry == dentry))
/* found */
goto exit;
}
#include <swap-asm/swap_kprobes.h>
-#ifdef CONFIG_ARM
-
-#define regs_return_value(regs) ((regs)->ARM_r0)
-
-#endif
-
-
/* kprobe_status settings */
/** Kprobe hit active */
#define KPROBE_HIT_ACTIVE 0x00000001
unsigned int fault_flags = 0;
/* For mlock, just skip the stack guard page. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
+ if (foll_flags & FOLL_POPULATE) {
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) */
if (foll_flags & FOLL_MLOCK) {
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0) */
if (stack_guard_page(vma, start))
goto next_page;
}
#define _SWAP_KPROBES_DEPS_H
#include <linux/version.h> /* LINUX_VERSION_CODE, KERNEL_VERSION() */
+#include <linux/mm.h>
#include <linux/hugetlb.h>
#include <linux/mempolicy.h>
#include <linux/highmem.h>
unsigned long flags, unsigned long pgoff);
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) */
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0)
+#define swap_hlist_add_after(node, prev) hlist_add_behind(node, prev)
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
+#define swap_hlist_add_after(node, prev) hlist_add_after(node, prev)
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 0)
+#define __get_cpu_var(var) (*this_cpu_ptr(&(var)))
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 0) */
#endif /* _SWAP_KPROBES_DEPS_H */
if (!task || !file)
return -EINVAL;
- dentry = file->f_dentry;
+ dentry = file->f_path.dentry;
/* check if it is a regular file */
if (!S_ISREG(dentry->d_inode->i_mode))
ksf_msg_file_entry(fd, fprobe->subtype,
fops_fpath(file, buf, PATH_LEN));
- priv->dentry = file->f_dentry;
+ priv->dentry = file->f_path.dentry;
} else {
priv->dentry = NULL;
}
ksf_msg_file_entry(fd, subtype, filepath);
}
- priv->dentry = file->f_dentry;
+ priv->dentry = file->f_path.dentry;
priv->subtype = subtype;
} else {
priv->dentry = NULL;
struct file *file = fops_karg(struct file *, regs, 0);
if (rp && file && file_count(file)) {
- struct dentry *dentry = file->f_dentry;
+ struct dentry *dentry = file->f_path.dentry;
/* release the file if it is going to be removed soon */
if (dentry && fops_dcount(dentry) == 2)
#define __FILE_OPS__
#include <linux/types.h>
+#include <kprobe/swap_kprobes_deps.h>
bool file_ops_is_init(void);
int file_ops_init(void);
#include <linux/sched.h>
#include <linux/dcache.h>
#include <linux/fdtable.h>
+#include <linux/version.h>
#include <writer/swap_msg.h>
#include <master/swap_deps.h>
#include <us_manager/sspt/sspt.h> /* ... check_vma() */
#endif /* CONFIG_arch */
}
+static inline struct timespec get_task_start_time(struct task_struct *task)
+{
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0)
+ return ns_to_timespec(task->real_start_time);
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
+ return task->real_start_time;
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
+}
+
+
static int pack_path(void *data, size_t size, struct file *file)
{
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (vma->vm_file && (vma->vm_flags & VM_EXEC) &&
- (vma->vm_file->f_dentry == dentry))
+ (vma->vm_file->f_path.dentry == dentry))
goto out;
}
return -ENOMEM;
getboottime(&boot_time);
- start_time = timespec_add(boot_time, task->real_start_time);
+ start_time = timespec_add(boot_time, get_task_start_time(task));
pib->ppid = task->real_parent->tgid;
pib->start_time = swap_msg_spec2time(&start_time);
if (unlikely(vma == NULL || vma->vm_file == NULL))
goto get_caller_dentry_fail;
- return vma->vm_file->f_dentry;
+ return vma->vm_file->f_path.dentry;
get_caller_dentry_fail:
/* jump only if caller is instumented and it is not a system lib -
* this leads to some errors */
if (cvma != NULL && cvma->vm_file != NULL &&
- cvma->vm_file->f_dentry != NULL) {
+ cvma->vm_file->f_path.dentry != NULL) {
- struct dentry *dentry = cvma->vm_file->f_dentry;
+ struct dentry *dentry = cvma->vm_file->f_path.dentry;
struct pd_t *pd = preload_pd_get_parent_pd(hd);
if (!preload_control_check_dentry_is_ignored(dentry) &&
for (vma = task->mm->mmap; vma; vma = vma->vm_next) {
if (vma->vm_file && vma->vm_flags & VM_EXEC
- && vma->vm_file->f_dentry == ld_info->dentry) {
+ && vma->vm_file->f_path.dentry == ld_info->dentry) {
preload_storage_put_linker_info(ld_info);
return vma;
}
if (!file)
return 0;
-
- dentry = file->f_dentry;
+ dentry = file->f_path.dentry;
if (dentry == NULL)
return 0;
{
struct file *file = vma->vm_file;
- return (file && (vma->vm_flags & VM_EXEC) && (file->f_dentry == dentry));
+ return (file && (vma->vm_flags & VM_EXEC) &&
+ (file->f_path.dentry == dentry));
}
static inline unsigned long __get_loader_base(struct pd_t *pd)
#include <linux/types.h>
+#include <linux/version.h>
+#include <kprobe/swap_kprobes_deps.h>
#include "sampler_timers.h"
urinst = urinst_info_create(ri);
if (urinst) {
if (last)
- hlist_add_after(last, &urinst->hlist);
+ swap_hlist_add_after(last, &urinst->hlist);
else
hlist_add_head(&urinst->hlist, head);
return 0;
for (vma = mm->mmap; vma; vma = vma->vm_next) {
- if (check_vma(vma) && vma->vm_file->f_dentry == dentry)
+ if (check_vma(vma) && vma->vm_file->f_path.dentry == dentry)
return 1;
}
vma = find_vma_intersection(mm, page_addr, page_addr + 1);
if (vma && check_vma(vma)) {
- struct dentry *dentry = vma->vm_file->f_dentry;
+ struct dentry *dentry = vma->vm_file->f_path.dentry;
struct sspt_file *file = sspt_proc_find_file(proc, dentry);
if (file) {
struct sspt_page *page;
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (check_vma(vma)) {
- struct dentry *dentry = vma->vm_file->f_dentry;
+ struct dentry *dentry = vma->vm_file->f_path.dentry;
struct sspt_file *file =
sspt_proc_find_file(proc, dentry);
if (file) {
vma = find_vma_intersection(current->mm, page_vaddr, page_vaddr + 1);
if (vma && check_vma(vma)) {
unsigned long addr = vaddr - vma->vm_start;
- struct dentry *d = vma->vm_file->f_dentry;
+ struct dentry *d = vma->vm_file->f_path.dentry;
if (addr == web_prof_addr(WILL_EXECUTE) &&
d == web_prof_lib_dentry()) {
vma = find_vma_intersection(current->mm, page_vaddr, page_vaddr + 1);
if (vma && check_vma(vma)) {
unsigned long addr = vaddr - vma->vm_start;
- struct dentry *d = vma->vm_file->f_dentry;
+ struct dentry *d = vma->vm_file->f_path.dentry;
if (addr == web_prof_addr(INSPSERVER_START) &&
d == web_prof_lib_dentry()) {
#ifndef _SWAP_MSG_H
#define _SWAP_MSG_H
+#include <linux/version.h>
+#include <linux/types.h>
+
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0)
+
+#include <linux/ktime.h> /* Needed by timekeeping.h */
+#include <linux/timekeeping.h> /* Now getnstimeofday() is here */
+
+#else /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
#include <linux/time.h>
-#include <linux/types.h>
+#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3, 16, 0) */
enum swap_msg_id {
MSG_PROC_INFO = 0x0001,