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: Add fallback if user didn't implement 'get_cred_rcu'
https://github.com/tiann/KernelSU/pull/2320 Signed-off-by: rsuntk <rissu.ntk@gmail.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user