kernel: try introduce like susfs's method to fix prctl delay
Co-authored-by: AlexLiuDev233 <wzylin11@outlook.com>
This commit is contained in:
@@ -471,6 +471,9 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
|
||||
u32 *result = (u32 *)arg5;
|
||||
u32 reply_ok = KERNEL_SU_OPTION;
|
||||
uid_t current_uid_val = current_uid().val;
|
||||
if (likely(ksu_is_current_proc_umounted())) { // prevent side channel attack in ksu side
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KSU_MANUAL_SU
|
||||
is_manual_su_cmd = (arg2 == CMD_SU_ESCALATION_REQUEST ||
|
||||
@@ -1082,6 +1085,10 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
|
||||
// try umount ksu temp path
|
||||
try_umount("/debug_ramdisk", false, MNT_DETACH);
|
||||
|
||||
get_task_struct(current); // delay fix
|
||||
ksu_set_current_proc_umounted();
|
||||
put_task_struct(current);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,19 @@
|
||||
|
||||
#include <linux/init.h>
|
||||
#include "apk_sign.h"
|
||||
#include <linux/thread_info.h>
|
||||
|
||||
void __init ksu_core_init(void);
|
||||
void ksu_core_exit(void);
|
||||
|
||||
#define KSU_PROC_UMOUNT 50
|
||||
|
||||
static inline bool ksu_is_current_proc_umounted(void) {
|
||||
return test_ti_thread_flag(¤t->thread_info, KSU_PROC_UMOUNT);
|
||||
}
|
||||
|
||||
static inline void ksu_set_current_proc_umounted(void) {
|
||||
set_ti_thread_flag(¤t->thread_info, KSU_PROC_UMOUNT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user