diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 2fbb42a1..b2a3eccf 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -118,6 +118,7 @@ static void setup_groups(struct root_profile *profile, struct cred *cred) groups_sort(group_info); set_groups(cred, group_info); + put_group_info(group_info); } static void disable_seccomp(void) @@ -142,27 +143,17 @@ void escape_to_root(void) { struct cred *cred; -#ifdef KSU_GET_CRED_RCU - rcu_read_lock(); - - do { - cred = (struct cred *)__task_cred((current)); - BUG_ON(!cred); - } while (!get_cred_rcu(cred)); + cred = prepare_creds(); + if (!cred) { + pr_warn("prepare_creds failed!\n"); + return; + } if (cred->euid.val == 0) { pr_warn("Already root, don't escape!\n"); - rcu_read_unlock(); + abort_creds(cred); return; } -#else - cred = (struct cred *)__task_cred(current); - - if (cred->euid.val == 0) { - pr_warn("Already root, don't escape!\n"); - return; - } -#endif struct root_profile *profile = ksu_get_root_profile(cred->uid.val); @@ -198,9 +189,7 @@ void escape_to_root(void) setup_groups(profile, cred); -#ifdef KSU_GET_CRED_RCU - rcu_read_unlock(); -#endif + commit_creds(cred); // Refer to kernel/seccomp.c: seccomp_set_mode_strict // When disabling Seccomp, ensure that current->sighand->siglock is held during the operation. @@ -267,7 +256,7 @@ static void nuke_ext4_sysfs() { } ext4_unregister_sysfs(sb); - path_put(&path); + path_put(&path); } int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,