Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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()
Expand All @@ -132,18 +133,18 @@ void escape_to_root(void)
{
struct cred *cred;

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;
}

struct root_profile *profile = ksu_get_root_profile(cred->uid.val);

cred->uid.val = profile->uid;
Expand Down Expand Up @@ -174,7 +175,7 @@ void escape_to_root(void)

setup_groups(profile, cred);

rcu_read_unlock();
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.
Expand Down Expand Up @@ -241,7 +242,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,
Expand Down