You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
kernel/sucompat: sync to KSU pr #2506
kernel: sucompat: sucompat toggle support for non-kp
This is done like how vfs_read_hook, input_hook and execve_hook is disabled.
While this is not exactly the same thing, this CAN achieve the same results.
The complete disabling of all KernelSU hooks.
While this is likely unneeded, It keeps feature parity to non-kprobe builds.
adapted from upstream:
kernel: Allow to re-enable sucompat - 4593ae81c7
Rejected: https://github.com/tiann/KernelSU/pull/2506
Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
kernel: sucompat: fix compile issue on kprobe builds, unused variable
This commit is contained in:
@@ -24,11 +24,9 @@
|
|||||||
#define SU_PATH "/system/bin/su"
|
#define SU_PATH "/system/bin/su"
|
||||||
#define SH_PATH "/system/bin/sh"
|
#define SH_PATH "/system/bin/sh"
|
||||||
|
|
||||||
bool ksu_faccessat_hook __read_mostly = true;
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
bool ksu_stat_hook __read_mostly = true;
|
static bool ksu_sucompat_non_kp __read_mostly = true;
|
||||||
bool ksu_execve_sucompat_hook __read_mostly = true;
|
#endif
|
||||||
bool ksu_execveat_sucompat_hook __read_mostly = true;
|
|
||||||
bool ksu_devpts_hook __read_mostly = true;
|
|
||||||
|
|
||||||
extern void escape_to_root();
|
extern void escape_to_root();
|
||||||
|
|
||||||
@@ -61,7 +59,7 @@ int ksu_handle_faccessat(int *dfd, const char __user **filename_user, int *mode,
|
|||||||
const char su[] = SU_PATH;
|
const char su[] = SU_PATH;
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_WITH_KPROBES
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
if (!ksu_faccessat_hook) {
|
if (!ksu_sucompat_non_kp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -88,7 +86,7 @@ int ksu_handle_stat(int *dfd, const char __user **filename_user, int *flags)
|
|||||||
const char su[] = SU_PATH;
|
const char su[] = SU_PATH;
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_WITH_KPROBES
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
if (!ksu_stat_hook){
|
if (!ksu_sucompat_non_kp){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -138,7 +136,7 @@ int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,
|
|||||||
const char su[] = SU_PATH;
|
const char su[] = SU_PATH;
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_WITH_KPROBES
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
if (!ksu_execveat_sucompat_hook) {
|
if (!ksu_sucompat_non_kp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -173,7 +171,7 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
|
|||||||
char path[sizeof(su) + 1];
|
char path[sizeof(su) + 1];
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_WITH_KPROBES
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
if (!ksu_execve_sucompat_hook) {
|
if (!ksu_sucompat_non_kp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -201,7 +199,7 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user,
|
|||||||
int ksu_handle_devpts(struct inode *inode)
|
int ksu_handle_devpts(struct inode *inode)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_KSU_WITH_KPROBES
|
#ifndef CONFIG_KSU_WITH_KPROBES
|
||||||
if (!ksu_devpts_hook) {
|
if (!ksu_sucompat_non_kp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -323,11 +321,7 @@ void ksu_sucompat_init()
|
|||||||
su_kps[2] = init_kprobe(SYS_NEWFSTATAT_SYMBOL, newfstatat_handler_pre);
|
su_kps[2] = init_kprobe(SYS_NEWFSTATAT_SYMBOL, newfstatat_handler_pre);
|
||||||
su_kps[3] = init_kprobe("pts_unix98_lookup", pts_unix98_lookup_pre);
|
su_kps[3] = init_kprobe("pts_unix98_lookup", pts_unix98_lookup_pre);
|
||||||
#else
|
#else
|
||||||
ksu_faccessat_hook = true;
|
ksu_sucompat_non_kp = true;
|
||||||
ksu_stat_hook = true;
|
|
||||||
ksu_execve_sucompat_hook = true;
|
|
||||||
ksu_execveat_sucompat_hook = true;
|
|
||||||
ksu_devpts_hook = true;
|
|
||||||
pr_info("ksu_sucompat_init: hooks enabled: execve/execveat_su, faccessat, stat, devpts\n");
|
pr_info("ksu_sucompat_init: hooks enabled: execve/execveat_su, faccessat, stat, devpts\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -339,11 +333,7 @@ void ksu_sucompat_exit()
|
|||||||
destroy_kprobe(&su_kps[i]);
|
destroy_kprobe(&su_kps[i]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ksu_faccessat_hook = false;
|
ksu_sucompat_non_kp = false;
|
||||||
ksu_stat_hook = false;
|
|
||||||
ksu_execve_sucompat_hook = false;
|
|
||||||
ksu_execveat_sucompat_hook = false;
|
|
||||||
ksu_devpts_hook = false;
|
|
||||||
pr_info("ksu_sucompat_exit: hooks disabled: execve/execveat_su, faccessat, stat, devpts\n");
|
pr_info("ksu_sucompat_exit: hooks disabled: execve/execveat_su, faccessat, stat, devpts\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user