fix: fix 5.0- users can't build (#551)

my mistake, forget old kernel's access_ok has 3 params,
so i switch to ksu_access_ok
This commit is contained in:
AlexLiuDev233
2025-11-08 21:33:21 +08:00
committed by ShirkNeko
parent a4d642bf50
commit d918e016bc
3 changed files with 18 additions and 14 deletions

View File

@@ -3,4 +3,7 @@ obj-y += compact.o
obj-y += super_access.o obj-y += super_access.o
ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
ccflags-y += -Wno-declaration-after-statement -Wno-unused-function 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

View File

@@ -37,6 +37,7 @@
#endif #endif
#include "kpm.h" #include "kpm.h"
#include "compact.h" #include "compact.h"
#include "../kernel_compat.h"
#define KPM_NAME_LEN 32 #define KPM_NAME_LEN 32
#define KPM_ARGS_LEN 1024 #define KPM_ARGS_LEN 1024
@@ -127,18 +128,18 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u
goto exit; goto exit;
} }
if (!access_ok(arg1, 255)) { if (!ksu_access_ok(arg1, sizeof(kernel_load_path))) {
goto invalid_arg; 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 (arg2 != 0) {
if (!access_ok(arg2, 255)) { if (!ksu_access_ok(arg2, sizeof(kernel_args_buffer))) {
goto invalid_arg; 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, 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; goto exit;
} }
if (!access_ok(arg1, sizeof(kernel_name_buffer))) { if (!ksu_access_ok(arg1, sizeof(kernel_name_buffer))) {
goto invalid_arg; goto invalid_arg;
} }
@@ -170,7 +171,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u
goto exit; goto exit;
} }
if (!access_ok(arg1, sizeof(kernel_name_buffer))) { if (!ksu_access_ok(arg1, sizeof(kernel_name_buffer))) {
goto invalid_arg; 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); 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; goto invalid_arg;
} }
@@ -193,7 +194,7 @@ noinline int sukisu_handle_kpm(unsigned long control_code, unsigned long arg1, u
goto exit; goto exit;
} }
if (!access_ok(arg2, len)) { if (!ksu_access_ok(arg2, len)) {
goto invalid_arg; 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_name[KPM_NAME_LEN] = { 0 };
char kpm_args[KPM_ARGS_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; goto invalid_arg;
} }
if (!access_ok(arg2, sizeof(kpm_args))) { if (!ksu_access_ok(arg2, sizeof(kpm_args))) {
goto invalid_arg; goto invalid_arg;
} }
@@ -267,12 +268,12 @@ int do_kpm(void __user *arg)
return -EFAULT; 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); pr_err("kpm: invalid control_code pointer %px\n", (void *)cmd.control_code);
return -EFAULT; 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); pr_err("kpm: invalid result_code pointer %px\n", (void *)cmd.result_code);
return -EFAULT; return -EFAULT;
} }

View File

@@ -11,7 +11,7 @@ struct ksu_kpm_cmd {
__aligned_u64 __user result_code; __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 sukisu_is_kpm_control_code(unsigned long control_code);
int do_kpm(void __user *arg); int do_kpm(void __user *arg);