From 34742da866781dc04e943c65d697b29666638029 Mon Sep 17 00:00:00 2001 From: bmax Date: Wed, 3 Apr 2024 22:35:05 +0800 Subject: [PATCH] a --- kernel/linux/include/linux/uaccess.h | 2 +- kernel/patch/android/sucompat.c | 8 ++++---- kernel/patch/android/supercall.c | 2 +- kernel/patch/android/userd.c | 8 ++++---- kernel/patch/common/supercall.c | 18 +++++++++--------- kernel/patch/common/utils.c | 4 ++-- kpms/demo-syscallhook/syscallhook.c | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/kernel/linux/include/linux/uaccess.h b/kernel/linux/include/linux/uaccess.h index 1356b5b9..4400e034 100644 --- a/kernel/linux/include/linux/uaccess.h +++ b/kernel/linux/include/linux/uaccess.h @@ -60,6 +60,6 @@ extern long kfunc_def(strnlen_user_nofault)(const void __user *unsafe_addr, long extern long kfunc_def(strnlen_unsafe_user)(const void __user *unsafe_addr, long count); extern long kfunc_def(strnlen_user)(const char __user *str, long n); -long compact_strncpy_from_user(char *dest, const char __user *src, long count); +long compat_strncpy_from_user(char *dest, const char __user *src, long count); #endif \ No newline at end of file diff --git a/kernel/patch/android/sucompat.c b/kernel/patch/android/sucompat.c index def9f630..36eba046 100644 --- a/kernel/patch/android/sucompat.c +++ b/kernel/patch/android/sucompat.c @@ -259,7 +259,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen char __user *ufilename = *u_filename_p; char filename[SU_PATH_MAX_LEN]; - int flen = compact_strncpy_from_user(filename, ufilename, sizeof(filename)); + int flen = compat_strncpy_from_user(filename, ufilename, sizeof(filename)); if (flen <= 0) return; if (!strcmp(current_su_path, filename)) { @@ -341,7 +341,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen // auth key char arg1[SUPER_KEY_LEN]; - if (compact_strncpy_from_user(arg1, p1, sizeof(arg1)) <= 0) return; + if (compat_strncpy_from_user(arg1, p1, sizeof(arg1)) <= 0) return; if (auth_superkey(arg1)) return; commit_su(0, 0); @@ -355,7 +355,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen if (p1 && !IS_ERR(p2)) { char buffer[EMBEDDED_NAME_MAX]; - int len = compact_strncpy_from_user(buffer, p2, EMBEDDED_NAME_MAX); + int len = compat_strncpy_from_user(buffer, p2, EMBEDDED_NAME_MAX); if (len >= 0) { exec = buffer; exec_len = len; @@ -447,7 +447,7 @@ static void su_handler_arg1_ufilename_before(hook_fargs6_t *args, void *udata) char __user *ufilename = (char __user *)syscall_argn(args, 1); char filename[SU_PATH_MAX_LEN]; - int flen = compact_strncpy_from_user(filename, ufilename, sizeof(filename)); + int flen = compat_strncpy_from_user(filename, ufilename, sizeof(filename)); if (flen <= 0) return; if (!strcmp(current_su_path, filename)) { diff --git a/kernel/patch/android/supercall.c b/kernel/patch/android/supercall.c index a336b7e8..413a6876 100644 --- a/kernel/patch/android/supercall.c +++ b/kernel/patch/android/supercall.c @@ -52,7 +52,7 @@ static long call_su_allow_uid_profile(uid_t uid, struct su_profile *__user uprof static long call_reset_su_path(const char *__user upath) { char path[SU_PATH_MAX_LEN]; - compact_strncpy_from_user(path, upath, sizeof(path)); + compat_strncpy_from_user(path, upath, sizeof(path)); return su_reset_path(path); } diff --git a/kernel/patch/android/userd.c b/kernel/patch/android/userd.c index f1645462..38d6e5eb 100644 --- a/kernel/patch/android/userd.c +++ b/kernel/patch/android/userd.c @@ -147,7 +147,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen char __user *ufilename = *u_filename_p; char filename[SU_PATH_MAX_LEN]; - int flen = compact_strncpy_from_user(filename, ufilename, sizeof(filename)); + int flen = compat_strncpy_from_user(filename, ufilename, sizeof(filename)); if (flen <= 0) return; if (!strcmp(system_bin_init, filename) || !strcmp(root_init, filename)) { @@ -164,7 +164,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen if (!p1 || IS_ERR(p1)) break; char arg[16] = { '\0' }; - if (compact_strncpy_from_user(arg, p1, sizeof(arg)) <= 0) break; + if (compat_strncpy_from_user(arg, p1, sizeof(arg)) <= 0) break; if (!strcmp(arg, "second_stage") || !strcmp(arg, "--second-stage")) { log_boot("exec %s second stage 0\n", filename); @@ -180,7 +180,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen if (!uenv || IS_ERR(uenv)) break; char env[256]; - if (compact_strncpy_from_user(env, uenv, sizeof(env)) <= 0) break; + if (compat_strncpy_from_user(env, uenv, sizeof(env)) <= 0) break; char *env_name = env; char *env_value = strchr(env, '='); if (env_value) { @@ -301,7 +301,7 @@ static void before_openat(hook_fargs4_t *args, void *udata) const char __user *filename = (typeof(filename))syscall_argn(args, 1); char buf[32]; - compact_strncpy_from_user(buf, filename, sizeof(buf)); + compat_strncpy_from_user(buf, filename, sizeof(buf)); if (strcmp(ORIGIN_RC_FILE, buf)) return; replaced = 1; diff --git a/kernel/patch/common/supercall.c b/kernel/patch/common/supercall.c index 9a34d689..3d3bd33f 100644 --- a/kernel/patch/common/supercall.c +++ b/kernel/patch/common/supercall.c @@ -68,7 +68,7 @@ static long call_panic() static long call_klog(const char __user *arg1) { char buf[1024]; - long len = compact_strncpy_from_user(buf, arg1, sizeof(buf)); + long len = compat_strncpy_from_user(buf, arg1, sizeof(buf)); if (len <= 0) return -EINVAL; if (len > 0) logki("user log: %s", buf); return 0; @@ -77,25 +77,25 @@ static long call_klog(const char __user *arg1) static long call_kpm_load(const char __user *arg1, const char *__user arg2, void *__user reserved) { char path[1024], args[KPM_ARGS_LEN]; - long pathlen = compact_strncpy_from_user(path, arg1, sizeof(path)); + long pathlen = compat_strncpy_from_user(path, arg1, sizeof(path)); if (pathlen <= 0) return -EINVAL; - long arglen = compact_strncpy_from_user(args, arg2, sizeof(args)); + long arglen = compat_strncpy_from_user(args, arg2, sizeof(args)); return load_module_path(path, arglen <= 0 ? 0 : args, reserved); } static long call_kpm_control(const char __user *arg1, const char *__user arg2, void *__user out_msg, int outlen) { char name[KPM_NAME_LEN], args[KPM_ARGS_LEN]; - long namelen = compact_strncpy_from_user(name, arg1, sizeof(name)); + long namelen = compat_strncpy_from_user(name, arg1, sizeof(name)); if (namelen <= 0) return -EINVAL; - long arglen = compact_strncpy_from_user(args, arg2, sizeof(args)); + long arglen = compat_strncpy_from_user(args, arg2, sizeof(args)); return module_control0(name, arglen <= 0 ? 0 : args, out_msg, outlen); } static long call_kpm_unload(const char *__user arg1, void *__user reserved) { char name[KPM_NAME_LEN]; - long len = compact_strncpy_from_user(name, arg1, sizeof(name)); + long len = compat_strncpy_from_user(name, arg1, sizeof(name)); if (len <= 0) return -EINVAL; return unload_module(name, reserved); } @@ -120,7 +120,7 @@ static long call_kpm_info(const char *__user uname, char *__user out_info, int o if (out_len <= 0) return -EINVAL; char name[64]; char buf[2048]; - int len = compact_strncpy_from_user(name, uname, sizeof(name)); + int len = compat_strncpy_from_user(name, uname, sizeof(name)); if (len <= 0) return -EINVAL; int sz = get_module_info(name, buf, sizeof(buf)); if (sz < 0) return sz; @@ -161,7 +161,7 @@ static long call_skey_get(char *__user out_key, int out_len) static long call_skey_set(char *__user new_key) { char buf[SUPER_KEY_LEN]; - int len = compact_strncpy_from_user(buf, new_key, sizeof(buf)); + int len = compat_strncpy_from_user(buf, new_key, sizeof(buf)); if (len >= SUPER_KEY_LEN && buf[SUPER_KEY_LEN - 1]) return -E2BIG; reset_superkey(new_key); return 0; @@ -249,7 +249,7 @@ static void before(hook_fargs6_t *args, void *udata) if (cmd < SUPERCALL_HELLO || cmd > SUPERCALL_MAX) return; char key[MAX_KEY_LEN]; - long len = compact_strncpy_from_user(key, ukey, MAX_KEY_LEN); + long len = compat_strncpy_from_user(key, ukey, MAX_KEY_LEN); if (len <= 0) return; if (auth_superkey(key)) return; diff --git a/kernel/patch/common/utils.c b/kernel/patch/common/utils.c index e21bc72f..6ae68dc3 100644 --- a/kernel/patch/common/utils.c +++ b/kernel/patch/common/utils.c @@ -94,7 +94,7 @@ KP_EXPORT_SYMBOL(compat_copy_to_user); #include -long compact_strncpy_from_user(char *dest, const char __user *src, long count) +long compat_strncpy_from_user(char *dest, const char __user *src, long count) { kfunc_call(strncpy_from_user_nofault, dest, src, count); kfunc_call(strncpy_from_unsafe_user, dest, src, count); @@ -110,7 +110,7 @@ long compact_strncpy_from_user(char *dest, const char __user *src, long count) } return 0; } -KP_EXPORT_SYMBOL(compact_strncpy_from_user); +KP_EXPORT_SYMBOL(compat_strncpy_from_user); int16_t pt_regs_offset = -1; diff --git a/kpms/demo-syscallhook/syscallhook.c b/kpms/demo-syscallhook/syscallhook.c index d7855343..a4b78af5 100644 --- a/kpms/demo-syscallhook/syscallhook.c +++ b/kpms/demo-syscallhook/syscallhook.c @@ -40,7 +40,7 @@ void before_openat_0(hook_fargs4_t *args, void *udata) umode_t mode = (int)syscall_argn(args, 3); char buf[1024]; - compact_strncpy_from_user(buf, filename, sizeof(buf)); + compat_strncpy_from_user(buf, filename, sizeof(buf)); struct task_struct *task = current; pid_t pid = -1, tgid = -1;