KernelSU: SUS_SU: Initiate path with 0 and no memset is needed

1. kernel & KernelSU: More optimization for SUS_SU mode 2 (Experimental)

2. Always flag zygote spawned isolated service as non-root user app process and no su allowed process

3. Change susfs_fake_qstr_name, shorter length

4. KernelSU: SUS_SU: Initiate path with 0 and no memset is needed

Co-authored-by: simonpunk <simonpunk2016@gmail.com>
This commit is contained in:
ShirkNeko
2025-07-15 10:24:43 +08:00
parent 0b03cd9faf
commit 329b7f59dc
2 changed files with 46 additions and 11 deletions

View File

@@ -65,12 +65,18 @@ int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
}
#endif
#ifndef CONFIG_KSU_SUSFS_SUS_SU
if (!ksu_is_allow_uid(current_uid().val)) {
return 0;
}
#endif
#ifdef CONFIG_KSU_SUSFS_SUS_SU
char path[sizeof(su)] = {0};
#else
char path[sizeof(su) + 1];
memset(path, 0, sizeof(path));
#endif
ksu_strncpy_from_user_nofault(path, *filename_user, sizeof(path));
if (unlikely(!memcmp(path, su, sizeof(su)))) {
@@ -89,10 +95,6 @@ struct filename* susfs_ksu_handle_stat(int *dfd, const char __user **filename_us
return name;
}
if (!ksu_is_allow_uid(current_uid().val)) {
return name;
}
if (likely(memcmp(name->name, su, sizeof(su)))) {
return name;
}
@@ -113,16 +115,22 @@ int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
}
#endif
#ifndef CONFIG_KSU_SUSFS_SUS_SU
if (!ksu_is_allow_uid(current_uid().val)) {
return 0;
}
#endif
if (unlikely(!filename_user)) {
return 0;
}
#ifdef CONFIG_KSU_SUSFS_SUS_SU
char path[sizeof(su)] = {0};
#else
char path[sizeof(su) + 1];
memset(path, 0, sizeof(path));
#endif
// Remove this later!! we use syscall hook, so this will never happen!!!!!
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) && 0
// it becomes a `struct filename *` after 5.18
@@ -172,8 +180,10 @@ int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
if (likely(memcmp(filename->name, su, sizeof(su))))
return 0;
#ifndef CONFIG_KSU_SUSFS_SUS_SU
if (!ksu_is_allow_uid(current_uid().val))
return 0;
#endif
pr_info("do_execveat_common su found\n");
memcpy((void *)filename->name, ksud_path, sizeof(ksud_path));
@@ -187,8 +197,12 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
void *__never_use_argv, void *__never_use_envp,
int *__never_use_flags)
{
// const char su[] = SU_PATH;
//const char su[] = SU_PATH;
#ifdef CONFIG_KSU_SUSFS_SUS_SU
char path[sizeof(su)] = {0};
#else
char path[sizeof(su) + 1];
#endif
#ifndef CONFIG_KSU_KPROBES_HOOK
if (!ksu_sucompat_hook_state) {
@@ -215,7 +229,6 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
long len = strncpy_from_user(path, *filename_user, sizeof(path));
if (len <= 0 || len > sizeof(path))
return 0;
// strncpy_from_user_nofault does this too
path[sizeof(path) - 1] = '\0';