diff --git a/kernel/core_hook.c b/kernel/core_hook.c index ec3b3ebd..13a54895 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -110,7 +110,7 @@ static void setup_groups(struct root_profile *profile, struct cred *cred) set_groups(cred, group_info); } -static void disable_seccomp() +static void disable_seccomp(void) { assert_spin_locked(¤t->sighand->siglock); // disable seccomp @@ -132,6 +132,7 @@ void escape_to_root(void) { struct cred *cred; +#ifdef KSU_GET_CRED_RCU rcu_read_lock(); do { @@ -144,6 +145,15 @@ void escape_to_root(void) rcu_read_unlock(); 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); cred->uid.val = profile->uid; @@ -180,8 +190,10 @@ void escape_to_root(void) sizeof(cred->cap_ambient)); setup_groups(profile, cred); - + +#ifdef KSU_GET_CRED_RCU rcu_read_unlock(); +#endif // Refer to kernel/seccomp.c: seccomp_set_mode_strict // When disabling Seccomp, ensure that current->sighand->siglock is held during the operation.