diff --git a/kernel/core_hook.c b/kernel/core_hook.c index dae2805a..61d7ebeb 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -1,5 +1,5 @@ -#include "linux/compiler.h" -#include "linux/sched/signal.h" +#include +#include #include #include #include @@ -61,6 +61,7 @@ #include "selinux/selinux.h" #include "kernel_compat.h" #include "supercalls.h" +#include "sucompat.h" #include "sulog.h" @@ -1243,7 +1244,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) if (new_uid.val == 2000) { if (ksu_su_compat_enabled) { - set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT); + ksu_set_task_tracepoint_flag(current); } } @@ -1264,7 +1265,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) spin_lock_irq(¤t->sighand->siglock); ksu_seccomp_allow_cache(current->seccomp.filter, __NR_reboot); if (ksu_su_compat_enabled) { - set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT); + ksu_set_task_tracepoint_flag(current); } spin_unlock_irq(¤t->sighand->siglock); return 0; @@ -1278,12 +1279,12 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) spin_unlock_irq(¤t->sighand->siglock); } if (ksu_su_compat_enabled) { - set_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT); + ksu_set_task_tracepoint_flag(current); } } else { // Disable syscall tracepoint sucompat for non-allowed processes if (ksu_su_compat_enabled) { - clear_tsk_thread_flag(current, TIF_SYSCALL_TRACEPOINT); + ksu_clear_task_tracepoint_flag(current); } } diff --git a/kernel/ksud.c b/kernel/ksud.c index f37878dc..e6065c8d 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -26,6 +26,7 @@ #include "ksud.h" #include "kernel_compat.h" #include "selinux/selinux.h" +#include "sucompat.h" static const char KERNEL_SU_RC[] = "\n" @@ -83,7 +84,6 @@ void on_post_fs_data(void) done = true; pr_info("%s!\n", __func__); ksu_load_allow_list(); - extern void ksu_mark_running_process(void); pr_info("mark tif for running process\n"); ksu_mark_running_process(); ksu_observer_init(); diff --git a/kernel/sucompat.c b/kernel/sucompat.c index 47c0b718..5cd75104 100644 --- a/kernel/sucompat.c +++ b/kernel/sucompat.c @@ -30,6 +30,7 @@ #include "klog.h" // IWYU pragma: keep #include "ksud.h" #include "kernel_compat.h" +#include "sucompat.h" #include "sulog.h" #define SU_PATH "/system/bin/su" diff --git a/kernel/sucompat.h b/kernel/sucompat.h new file mode 100644 index 00000000..98e70b47 --- /dev/null +++ b/kernel/sucompat.h @@ -0,0 +1,26 @@ +#ifndef __KSU_H_SUCOMPAT +#define __KSU_H_SUCOMPAT +#include +#include +#include + +void ksu_mark_running_process(void); + +static inline void ksu_set_task_tracepoint_flag(struct task_struct *t) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + set_task_syscall_work(t, SYSCALL_TRACEPOINT); +#else + set_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); +#endif +} + +static inline void ksu_clear_task_tracepoint_flag(struct task_struct *t) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) + clear_task_syscall_work(t, SYSCALL_TRACEPOINT); +#else + clear_tsk_thread_flag(t, TIF_SYSCALL_TRACEPOINT); +#endif +} +#endif \ No newline at end of file