kernel: Fix compilation for non-gki kernels (#547)
* kernel: Fix compilation for non-gki kernels * kernel: Check if selinux_state exists rather than depends on version code
This commit is contained in:
@@ -153,6 +153,11 @@ ifeq ($(shell grep -q "struct proc_ops " $(srctree)/include/linux/proc_fs.h; ech
|
|||||||
ccflags-y += -DKSU_COMPAT_HAS_PROC_OPS
|
ccflags-y += -DKSU_COMPAT_HAS_PROC_OPS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Struct selinux_state check
|
||||||
|
ifeq ($(shell grep -q "struct selinux_state " $(srctree)/security/selinux/include/security.h; echo $$?),0)
|
||||||
|
ccflags-y += -DKSU_COMPAT_HAS_SELINUX_STATE
|
||||||
|
endif
|
||||||
|
|
||||||
# Custom Signs
|
# Custom Signs
|
||||||
ifdef KSU_EXPECTED_SIZE
|
ifdef KSU_EXPECTED_SIZE
|
||||||
ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
|
ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE)
|
||||||
|
|||||||
@@ -1063,7 +1063,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
if (!is_ksu_domain()) {
|
if (!is_ksu_domain()) {
|
||||||
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
||||||
current->pid, current->comm, old_uid.val, new_uid.val);
|
current->pid, current->comm, old_uid.val, new_uid.val);
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
|
||||||
force_sig(SIGKILL);
|
force_sig(SIGKILL);
|
||||||
|
#else
|
||||||
|
force_sig(SIGKILL, current);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1072,7 +1076,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
if (new_uid.val < old_uid.val && !ksu_is_allow_uid_for_current(old_uid.val)) {
|
if (new_uid.val < old_uid.val && !ksu_is_allow_uid_for_current(old_uid.val)) {
|
||||||
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
||||||
current->pid, current->comm, old_uid.val, new_uid.val);
|
current->pid, current->comm, old_uid.val, new_uid.val);
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
|
||||||
force_sig(SIGKILL);
|
force_sig(SIGKILL);
|
||||||
|
#else
|
||||||
|
force_sig(SIGKILL, current);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1239,7 +1247,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
if (!is_ksu_domain()) {
|
if (!is_ksu_domain()) {
|
||||||
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
||||||
current->pid, current->comm, old_uid.val, new_uid.val);
|
current->pid, current->comm, old_uid.val, new_uid.val);
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
|
||||||
force_sig(SIGKILL);
|
force_sig(SIGKILL);
|
||||||
|
#else
|
||||||
|
force_sig(SIGKILL, current);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1248,7 +1260,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
|||||||
if (new_uid.val < old_uid.val && !ksu_is_allow_uid_for_current(old_uid.val)) {
|
if (new_uid.val < old_uid.val && !ksu_is_allow_uid_for_current(old_uid.val)) {
|
||||||
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
pr_warn("find suspicious EoP: %d %s, from %d to %d\n",
|
||||||
current->pid, current->comm, old_uid.val, new_uid.val);
|
current->pid, current->comm, old_uid.val, new_uid.val);
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
|
||||||
force_sig(SIGKILL);
|
force_sig(SIGKILL);
|
||||||
|
#else
|
||||||
|
force_sig(SIGKILL, current);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ static int ksu_file_proxy_fadvise(struct file *fp, loff_t off1, loff_t off2, int
|
|||||||
static int ksu_wrapper_clone_file_range(struct file *file_in, loff_t pos_in,
|
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) {
|
struct file *file_out, loff_t pos_out, u64 len) {
|
||||||
// TODO: determine which file to use
|
// TODO: determine which file to use
|
||||||
struct ksu_file_wrapper* data = file_in->private_data;
|
struct ksu_file_proxy* data = file_in->private_data;
|
||||||
struct file* orig = data->orig;
|
struct file* orig = data->orig;
|
||||||
if (orig->f_op->clone_file_range) {
|
if (orig->f_op->clone_file_range) {
|
||||||
return orig->f_op->clone_file_range(orig, pos_in, file_out, pos_out, len);
|
return orig->f_op->clone_file_range(orig, pos_in, file_out, pos_out, len);
|
||||||
@@ -289,7 +289,7 @@ static int ksu_wrapper_clone_file_range(struct file *file_in, loff_t pos_in,
|
|||||||
static ssize_t ksu_wrapper_dedupe_file_range(struct file *src_file, u64 loff,
|
static ssize_t ksu_wrapper_dedupe_file_range(struct file *src_file, u64 loff,
|
||||||
u64 len, struct file *dst_file, u64 dst_loff) {
|
u64 len, struct file *dst_file, u64 dst_loff) {
|
||||||
// TODO: determine which file to use
|
// TODO: determine which file to use
|
||||||
struct ksu_file_wrapper* data = src_file->private_data;
|
struct ksu_file_proxy* data = src_file->private_data;
|
||||||
struct file* orig = data->orig;
|
struct file* orig = data->orig;
|
||||||
if (orig->f_op->dedupe_file_range) {
|
if (orig->f_op->dedupe_file_range) {
|
||||||
return orig->f_op->dedupe_file_range(orig, loff, len, dst_file, dst_loff);
|
return orig->f_op->dedupe_file_range(orig, loff, len, dst_file, dst_loff);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include "linux/sched.h"
|
#include "linux/sched.h"
|
||||||
|
|
||||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || defined(KSU_COMPAT_HAS_SELINUX_STATE)
|
#ifdef KSU_COMPAT_HAS_SELINUX_STATE
|
||||||
#define KSU_COMPAT_USE_SELINUX_STATE
|
#define KSU_COMPAT_USE_SELINUX_STATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user