diff --git a/kernel/kpm/Makefile b/kernel/kpm/Makefile index 3f75542d..37c28ba0 100644 --- a/kernel/kpm/Makefile +++ b/kernel/kpm/Makefile @@ -3,4 +3,7 @@ obj-y += compact.o obj-y += super_access.o ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat -ccflags-y += -Wno-declaration-after-statement -Wno-unused-function \ No newline at end of file +ccflags-y += -Wno-declaration-after-statement -Wno-unused-function + +ccflags-y += -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include +ccflags-y += -I$(objtree)/security/selinux -include $(srctree)/include/uapi/asm-generic/errno.h diff --git a/kernel/kpm/kpm.c b/kernel/kpm/kpm.c index 7b0640e8..85809414 100644 --- a/kernel/kpm/kpm.c +++ b/kernel/kpm/kpm.c @@ -37,6 +37,7 @@ #endif #include "kpm.h" #include "compact.h" +#include "../kernel_compat.h" #define KPM_NAME_LEN 32 #define KPM_ARGS_LEN 1024 @@ -127,18 +128,18 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u goto exit; } - if (!access_ok(arg1, 255)) { + if (!ksu_access_ok(arg1, sizeof(kernel_load_path))) { goto invalid_arg; } - strncpy_from_user((char *)&kernel_load_path, (const char *)arg1, 255); + strncpy_from_user((char *)&kernel_load_path, (const char *)arg1, sizeof(kernel_load_path)); if (arg2 != 0) { - if (!access_ok(arg2, 255)) { + if (!ksu_access_ok(arg2, sizeof(kernel_args_buffer))) { goto invalid_arg; } - strncpy_from_user((char *)&kernel_args_buffer, (const char *)arg2, 255); + strncpy_from_user((char *)&kernel_args_buffer, (const char *)arg2, sizeof(kernel_args_buffer)); } sukisu_kpm_load_module_path((const char *)&kernel_load_path, @@ -151,7 +152,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u goto exit; } - if (!access_ok(arg1, sizeof(kernel_name_buffer))) { + if (!ksu_access_ok(arg1, sizeof(kernel_name_buffer))) { goto invalid_arg; } @@ -170,7 +171,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u goto exit; } - if (!access_ok(arg1, sizeof(kernel_name_buffer))) { + if (!ksu_access_ok(arg1, sizeof(kernel_name_buffer))) { goto invalid_arg; } @@ -178,7 +179,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u sukisu_kpm_info((const char *)&kernel_name_buffer, (char *)&buf, sizeof(buf), &size); - if (!access_ok(arg2, size)) { + if (!ksu_access_ok(arg2, size)) { goto invalid_arg; } @@ -193,7 +194,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u goto exit; } - if (!access_ok(arg2, len)) { + if (!ksu_access_ok(arg2, len)) { goto invalid_arg; } @@ -211,11 +212,11 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u char kpm_name[KPM_NAME_LEN] = { 0 }; char kpm_args[KPM_ARGS_LEN] = { 0 }; - if (!access_ok(arg1, sizeof(kpm_name))) { + if (!ksu_access_ok(arg1, sizeof(kpm_name))) { goto invalid_arg; } - if (!access_ok(arg2, sizeof(kpm_args))) { + if (!ksu_access_ok(arg2, sizeof(kpm_args))) { goto invalid_arg; } @@ -267,12 +268,12 @@ int do_kpm(void __user *arg) return -EFAULT; } - if (!access_ok(cmd.control_code, sizeof(int))) { + if (!ksu_access_ok(cmd.control_code, sizeof(int))) { pr_err("kpm: invalid control_code pointer %px\n", (void *)cmd.control_code); return -EFAULT; } - if (!access_ok(cmd.result_code, sizeof(int))) { + if (!ksu_access_ok(cmd.result_code, sizeof(int))) { pr_err("kpm: invalid result_code pointer %px\n", (void *)cmd.result_code); return -EFAULT; } diff --git a/kernel/kpm/kpm.h b/kernel/kpm/kpm.h index ca62b05c..bc5f42f2 100644 --- a/kernel/kpm/kpm.h +++ b/kernel/kpm/kpm.h @@ -11,7 +11,7 @@ struct ksu_kpm_cmd { __aligned_u64 __user result_code; }; -int sukisu_handle_kpm(unsigned long control_code, unsigned long arg3, unsigned long arg4, unsigned long result_code); +int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, unsigned long arg2, unsigned long result_code); int sukisu_is_kpm_control_code(unsigned long control_code); int do_kpm(void __user *arg);