-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathsupercall.h
More file actions
172 lines (142 loc) · 6.56 KB
/
Copy pathsupercall.h
File metadata and controls
172 lines (142 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef __KSU_UAPI_SUPERCALL_H
#define __KSU_UAPI_SUPERCALL_H
#include <linux/ioctl.h>
#include <linux/types.h>
#include "uapi/app_profile.h"
// use __u32 to avoid we maybe have version more than 255
// yep, it's possible it will never be exceeded, just to prevent the possibility
static const __u32 KERNEL_SU_UAPI_VERSION = 1;
/* Magic numbers for reboot hook to install fd */
static const __u32 KSU_INSTALL_MAGIC1 = 0xDEADBEEF;
static const __u32 KSU_INSTALL_MAGIC2 = 0xCAFEBABE;
struct ksu_become_daemon_cmd {
__u8 token[65]; /* Input: daemon token (null-terminated) */
};
static const __u32 EVENT_POST_FS_DATA = 1;
static const __u32 EVENT_BOOT_COMPLETED = 2;
static const __u32 EVENT_MODULE_MOUNTED = 3;
static const __u32 KSU_GET_INFO_FLAG_LKM = (1U << 0);
static const __u32 KSU_GET_INFO_FLAG_MANAGER = (1U << 1);
static const __u32 KSU_GET_INFO_FLAG_LATE_LOAD = (1U << 2);
static const __u32 KSU_GET_INFO_FLAG_PR_BUILD = (1U << 3);
struct ksu_get_info_cmd {
__u32 version; /* Output: KERNEL_SU_VERSION */
__u32 flags; /* Output: KSU_GET_INFO_FLAG_* bits */
__u32 features; /* Output: max feature ID supported */
__u32 uapi_version; /* Output: KERNEL_SU_UAPI_VERSION */
};
struct ksu_report_event_cmd {
__u32 event; /* Input: EVENT_POST_FS_DATA, EVENT_BOOT_COMPLETED, etc. */
};
struct ksu_set_sepolicy_cmd {
__u64 data_len; /* Input: bytes of serialized command payload */
__aligned_u64 data; /* Input: pointer to serialized payload */
};
struct ksu_sepolicy_cmd_hdr {
__u32 cmd; /* Input: command type, CMD_* */
__u32 subcmd; /* Input: command subtype */
};
/*
* After each ksu_sepolicy_cmd_hdr, command arguments are encoded sequentially as:
* [u32 len][len bytes][\0], where len excludes the trailing '\0'.
* len == 0 represents ALL.
* Argument count is derived from cmd:
* KSU_SEPOLICY_CMD_NORMAL_PERM=4, KSU_SEPOLICY_CMD_XPERM=5,
* KSU_SEPOLICY_CMD_TYPE_STATE=1, KSU_SEPOLICY_CMD_TYPE=2,
* KSU_SEPOLICY_CMD_TYPE_ATTR=2, KSU_SEPOLICY_CMD_ATTR=1,
* KSU_SEPOLICY_CMD_TYPE_TRANSITION=5, KSU_SEPOLICY_CMD_TYPE_CHANGE=4,
* KSU_SEPOLICY_CMD_GENFSCON=3.
*/
struct ksu_check_safemode_cmd {
__u8 in_safe_mode; /* Output: true if in safe mode, false otherwise */
};
/* deprecated */
struct ksu_get_allow_list_cmd {
__u32 uids[128]; /* Output: array of allowed/denied UIDs */
__u32 count; /* Output: number of UIDs in array */
__u8 allow; /* Input: true for allow list, false for deny list */
};
struct ksu_new_get_allow_list_cmd {
__u16 count; /* Input / Output: number of UIDs in array */
__u16 total_count; /* Output: total number of UIDs in requested list */
__u32 uids[0]; /* Output: array of allowed/denied UIDs */
};
struct ksu_uid_granted_root_cmd {
__u32 uid; /* Input: target UID to check */
__u8 granted; /* Output: true if granted, false otherwise */
};
struct ksu_uid_should_umount_cmd {
__u32 uid; /* Input: target UID to check */
__u8 should_umount; /* Output: true if should umount, false otherwise */
};
struct ksu_get_manager_appid_cmd {
__u32 appid; /* Output: manager app id */
};
struct ksu_get_app_profile_cmd {
struct app_profile profile; /* Input/Output: app profile structure */
};
struct ksu_set_app_profile_cmd {
struct app_profile profile; /* Input: app profile structure */
};
struct ksu_get_feature_cmd {
__u32 feature_id; /* Input: feature ID (enum ksu_feature_id) */
__u64 value; /* Output: feature value/state */
__u8 supported; /* Output: true if feature is supported, false otherwise */
};
struct ksu_set_feature_cmd {
__u32 feature_id; /* Input: feature ID (enum ksu_feature_id) */
__u64 value; /* Input: feature value/state to set */
};
struct ksu_get_wrapper_fd_cmd {
__u32 fd; /* Input: userspace fd */
__u32 flags; /* Input: flags of userspace fd */
};
struct ksu_manage_mark_cmd {
__u32 operation; /* Input: KSU_MARK_* */
__s32 pid; /* Input: target pid (0 for all processes) */
__u32 result; /* Output: for get operation - mark status or reg_count */
};
static const __u32 KSU_MARK_GET = 1;
static const __u32 KSU_MARK_MARK = 2;
static const __u32 KSU_MARK_UNMARK = 3;
static const __u32 KSU_MARK_REFRESH = 4;
struct ksu_nuke_ext4_sysfs_cmd {
__aligned_u64 arg; /* Input: mnt pointer */
};
struct ksu_add_try_umount_cmd {
__aligned_u64 arg; /* char ptr, this is the mountpoint */
__u32 flags; /* this is the flag we use for it */
__u8 mode; /* denotes what to do with it 0:wipe_list 1:add_to_list 2:delete_entry */
};
struct ksu_get_sulog_fd_cmd {
__u32 flags; /* Input: reserved for future use, must be 0 */
};
static const __u8 KSU_UMOUNT_WIPE = 0; /* ignore everything and wipe list */
static const __u8 KSU_UMOUNT_ADD = 1; /* add entry (path + flags) */
static const __u8 KSU_UMOUNT_DEL = 2; /* delete entry, strcmp */
/* IOCTL command definitions */
static const __u32 KSU_IOCTL_GRANT_ROOT = _IOC(_IOC_NONE, 'K', 1, 0);
static const __u32 KSU_IOCTL_GET_INFO = _IOC(_IOC_READ, 'K', 2, 0);
static const __u32 KSU_IOCTL_REPORT_EVENT = _IOC(_IOC_WRITE, 'K', 3, 0);
static const __u32 KSU_IOCTL_SET_SEPOLICY = _IOC(_IOC_READ | _IOC_WRITE, 'K', 4, 0);
static const __u32 KSU_IOCTL_CHECK_SAFEMODE = _IOC(_IOC_READ, 'K', 5, 0);
/* deprecated */
static const __u32 KSU_IOCTL_GET_ALLOW_LIST = _IOC(_IOC_READ | _IOC_WRITE, 'K', 6, 0);
/* deprecated */
static const __u32 KSU_IOCTL_GET_DENY_LIST = _IOC(_IOC_READ | _IOC_WRITE, 'K', 7, 0);
static const __u32 KSU_IOCTL_NEW_GET_ALLOW_LIST = _IOWR('K', 6, struct ksu_new_get_allow_list_cmd);
static const __u32 KSU_IOCTL_NEW_GET_DENY_LIST = _IOWR('K', 7, struct ksu_new_get_allow_list_cmd);
static const __u32 KSU_IOCTL_UID_GRANTED_ROOT = _IOC(_IOC_READ | _IOC_WRITE, 'K', 8, 0);
static const __u32 KSU_IOCTL_UID_SHOULD_UMOUNT = _IOC(_IOC_READ | _IOC_WRITE, 'K', 9, 0);
static const __u32 KSU_IOCTL_GET_MANAGER_APPID = _IOC(_IOC_READ, 'K', 10, 0);
static const __u32 KSU_IOCTL_GET_APP_PROFILE = _IOC(_IOC_READ | _IOC_WRITE, 'K', 11, 0);
static const __u32 KSU_IOCTL_SET_APP_PROFILE = _IOC(_IOC_WRITE, 'K', 12, 0);
static const __u32 KSU_IOCTL_GET_FEATURE = _IOC(_IOC_READ | _IOC_WRITE, 'K', 13, 0);
static const __u32 KSU_IOCTL_SET_FEATURE = _IOC(_IOC_WRITE, 'K', 14, 0);
static const __u32 KSU_IOCTL_GET_WRAPPER_FD = _IOC(_IOC_WRITE, 'K', 15, 0);
static const __u32 KSU_IOCTL_MANAGE_MARK = _IOC(_IOC_READ | _IOC_WRITE, 'K', 16, 0);
static const __u32 KSU_IOCTL_NUKE_EXT4_SYSFS = _IOC(_IOC_WRITE, 'K', 17, 0);
static const __u32 KSU_IOCTL_ADD_TRY_UMOUNT = _IOC(_IOC_WRITE, 'K', 18, 0);
static const __u32 KSU_IOCTL_SET_INIT_PGRP = _IO('K', 19);
static const __u32 KSU_IOCTL_GET_SULOG_FD = _IOW('K', 20, struct ksu_get_sulog_fd_cmd);
#endif