kernel: return early for prctl command

This commit is contained in:
weishu
2023-02-22 14:26:53 +07:00
parent 0c3731b0bd
commit 09fb118d22

View File

@@ -200,10 +200,10 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
u32 version = KERNEL_SU_VERSION; u32 version = KERNEL_SU_VERSION;
if (copy_to_user(arg3, &version, sizeof(version))) { if (copy_to_user(arg3, &version, sizeof(version))) {
pr_err("prctl reply error, cmd: %d\n", arg2); pr_err("prctl reply error, cmd: %d\n", arg2);
}
}
return 0; return 0;
} }
}
}
if (arg2 == CMD_REPORT_EVENT) { if (arg2 == CMD_REPORT_EVENT) {
if (0 != current_uid().val) { if (0 != current_uid().val) {
@@ -257,7 +257,8 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
if (is_manager() || 0 == current_uid().val) { if (is_manager() || 0 == current_uid().val) {
u32 array[128]; u32 array[128];
u32 array_length; u32 array_length;
bool success = ksu_get_allow_list(array, &array_length, bool success =
ksu_get_allow_list(array, &array_length,
arg2 == CMD_GET_ALLOW_LIST); arg2 == CMD_GET_ALLOW_LIST);
if (success) { if (success) {
if (!copy_to_user(arg4, &array_length, if (!copy_to_user(arg4, &array_length,
@@ -274,6 +275,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
} }
} }
} }
return 0;
} }
// all other cmds are for 'root manager' // all other cmds are for 'root manager'
@@ -294,6 +296,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
} }
} }
ksu_show_allow_list(); ksu_show_allow_list();
return 0;
} }
return 0; return 0;
@@ -373,16 +376,13 @@ static int ksu_task_prctl(int option, unsigned long arg2, unsigned long arg3,
} }
// kernel 4.4 and 4.9 // kernel 4.4 and 4.9
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
static int ksu_key_permission(key_ref_t key_ref, static int ksu_key_permission(key_ref_t key_ref, const struct cred *cred,
const struct cred *cred,
unsigned perm) unsigned perm)
{ {
if (init_session_keyring != NULL) if (init_session_keyring != NULL) {
{
return 0; return 0;
} }
if (strcmp(current->comm, "init")) if (strcmp(current->comm, "init")) {
{
// we are only interested in `init` process // we are only interested in `init` process
return 0; return 0;
} }