diff --git a/kernel/allowlist.c b/kernel/allowlist.c index 52538ee0..152139f0 100644 --- a/kernel/allowlist.c +++ b/kernel/allowlist.c @@ -10,6 +10,9 @@ #include #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) +#include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) #include #endif @@ -418,7 +421,11 @@ void persistent_allow_list() goto put_task; } cb->func = do_persistent_allow_list; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0) task_work_add(tsk, cb, TWA_RESUME); +#else + task_work_add(tsk, cb, true); +#endif put_task: put_task_struct(tsk); diff --git a/kernel/file_wrapper.c b/kernel/file_wrapper.c index c5c105f9..432e0645 100644 --- a/kernel/file_wrapper.c +++ b/kernel/file_wrapper.c @@ -243,7 +243,6 @@ static void ksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f) { } } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) static ssize_t ksu_wrapper_copy_file_range(struct file *f1, loff_t off1, struct file *f2, loff_t off2, size_t sz, unsigned int flags) { // TODO: determine which file to use @@ -255,6 +254,7 @@ static ssize_t ksu_wrapper_copy_file_range(struct file *f1, loff_t off1, struct return -EINVAL; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) static loff_t ksu_wrapper_remap_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags) { @@ -266,6 +266,15 @@ static loff_t ksu_wrapper_remap_file_range(struct file *file_in, loff_t pos_in, } return -EINVAL; } + +static int ksu_wrapper_fadvise(struct file *fp, loff_t off1, loff_t off2, int flags) { + struct ksu_file_wrapper* data = fp->private_data; + struct file* orig = data->orig; + if (orig->f_op->fadvise) { + return orig->f_op->fadvise(orig, off1, off2, flags); + } + return -EINVAL; +} #else static int ksu_wrapper_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) { @@ -290,15 +299,6 @@ static ssize_t ksu_wrapper_dedupe_file_range(struct file *src_file, u64 loff, } #endif -static int ksu_wrapper_fadvise(struct file *fp, loff_t off1, loff_t off2, int flags) { - struct ksu_file_wrapper* data = fp->private_data; - struct file* orig = data->orig; - if (orig->f_op->fadvise) { - return orig->f_op->fadvise(orig, off1, off2, flags); - } - return -EINVAL; -} - static int ksu_wrapper_release(struct inode *inode, struct file *filp) { ksu_delete_file_wrapper(filp->private_data); return 0; diff --git a/kernel/ksud.c b/kernel/ksud.c index 6b0efc4e..1d18132b 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -10,6 +10,9 @@ #include #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) +#include +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) #include #else @@ -253,7 +256,11 @@ first_app_process: rcu_read_lock(); init_task = rcu_dereference(current->parent); if (init_task) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) task_work_add(init_task, &on_post_fs_data_cb, TWA_RESUME); +#else + task_work_add(init_task, &on_post_fs_data_cb, true); +#endif } rcu_read_unlock(); diff --git a/kernel/supercalls.c b/kernel/supercalls.c index c1e2f73b..878a8d8f 100644 --- a/kernel/supercalls.c +++ b/kernel/supercalls.c @@ -383,10 +383,16 @@ static int do_get_wrapper_fd(void __user *arg) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) #define getfd_secure anon_inode_create_getfd -#else +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) #define getfd_secure anon_inode_getfd_secure +#else +#define getfd_secure anon_inode_getfd #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) ret = getfd_secure("[ksu_fdwrapper]", &data->ops, data, f->f_flags, NULL); +#else + ret = getfd_secure("[ksu_fdwrapper]", &data->ops, data, f->f_flags); +#endif if (ret < 0) { pr_err("ksu_fdwrapper: getfd failed: %d\n", ret); goto put_wrapper_data;