Skip to content

Commit 9034086

Browse files
authored
kernel: added new prctl CMD_GET_MANAGER_UID to get the uid of the crowned manager (tiann#2673)
1 parent 9014c66 commit 9034086

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

kernel/core_hook.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,17 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
413413
return 0;
414414
}
415415

416+
if (arg2 == CMD_GET_MANAGER_UID) {
417+
uid_t manager_uid = ksu_get_manager_uid();
418+
if (copy_to_user(arg3, &manager_uid, sizeof(manager_uid))) {
419+
pr_err("get manager uid failed\n");
420+
}
421+
if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
422+
pr_err("prctl reply error, cmd: %lu\n", arg2);
423+
}
424+
return 0;
425+
}
426+
416427
// all other cmds are for 'root manager'
417428
if (!from_manager) {
418429
return 0;

kernel/ksu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define CMD_UID_SHOULD_UMOUNT 13
2424
#define CMD_IS_SU_ENABLED 14
2525
#define CMD_ENABLE_SU 15
26+
#define CMD_GET_MANAGER_UID 16
2627

2728
#define EVENT_POST_FS_DATA 1
2829
#define EVENT_BOOT_COMPLETED 2

0 commit comments

Comments
 (0)