Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/linux/apparmor.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _LINUX_APPARMOR_H 3 #define _LINUX_APPARMOR_H 4 5 #include <linux/types.h> 6 7 #define APPARMOR_MODESET_AUDIT 1 8 #define APPARMOR_MODESET_ALLOWED 2 9 #define APPARMOR_MODESET_ENFORCE 4 10 #define APPARMOR_MODESET_HINT 8 11 #define APPARMOR_MODESET_STATUS 16 12 #define APPARMOR_MODESET_ERROR 32 13 #define APPARMOR_MODESET_KILL 64 14 #define APPARMOR_MODESET_USER 128 15 16 #define APPARMOR_FLAG_NOCACHE 1 17 18 enum apparmor_notif_type { 19 APPARMOR_NOTIF_RESP_PERM, 20 APPARMOR_NOTIF_CANCEL, 21 APPARMOR_NOTIF_INTERUPT, 22 APPARMOR_NOTIF_ALIVE, 23 APPARMOR_NOTIF_OP, 24 APPARMOR_NOTIF_RESP_NAME, 25 }; 26 27 #define APPARMOR_NOTIFY_V3 3 28 #define APPARMOR_NOTIFY_V5 5 29 #define APPARMOR_NOTIFY_VERSION 5 30 31 /* base notification struct embedded as head of notifications to userspace */ 32 struct apparmor_notif_common { 33 __u16 len; /* actual len data */ 34 __u16 version; /* interface version */ 35 } __attribute__((packed)); 36 37 struct apparmor_notif_register_v5 { 38 struct apparmor_notif_common base; 39 __u64 listener_id; /* unique id for listener */ 40 } __attribute__((packed)); 41 42 struct apparmor_notif_resend_v5 { 43 struct apparmor_notif_common base; 44 __u64 listener_id; /* unique id for listener */ 45 __u32 ready; /* notifications that are ready */ 46 __u32 pending; /* notifs that are pendying reply */ 47 } __attribute__((packed)); 48 49 struct apparmor_notif_filter { 50 struct apparmor_notif_common base; 51 __u32 modeset; /* which notification mode */ 52 __u32 ns; /* offset into data */ 53 __u32 filter; /* offset into data */ 54 55 __u8 data[]; 56 } __attribute__((packed)); 57 58 // flags 59 #define URESPONSE_NO_CACHE 1 60 #define URESPONSE_LOOKUP 2 61 #define URESPONSE_PROFILE 4 62 #define URESPONSE_TAILGLOB 8 63 #define UNOTIF_RESENT 0x10 64 65 struct apparmor_notif { 66 struct apparmor_notif_common base; 67 __u16 ntype; /* notify type */ 68 __u8 signalled; 69 __u8 flags; 70 __u64 id; /* unique id, not gloablly unique*/ 71 __s32 error; /* error if unchanged */ 72 } __attribute__((packed)); 73 74 75 struct apparmor_notif_update { 76 struct apparmor_notif base; 77 __u16 ttl; /* max keep alives left */ 78 } __attribute__((packed)); 79 80 /* userspace response to notification that expects a response */ 81 struct apparmor_notif_resp_perm { 82 struct apparmor_notif base; 83 __s32 error; /* error if unchanged */ 84 __u32 allow; 85 __u32 deny; 86 } __attribute__((packed)); 87 88 struct apparmor_notif_resp_name { 89 union { 90 struct apparmor_notif base; 91 struct apparmor_notif_resp_perm perm; 92 }; 93 __u32 name; 94 __u8 data[]; 95 } __attribute__((packed)); 96 97 struct apparmor_notif_op { 98 struct apparmor_notif base; 99 __u32 allow; 100 __u32 deny; 101 pid_t pid; /* pid of task causing notification */ 102 __u32 label; /* offset into data */ 103 __u16 class; 104 __u16 op; 105 } __attribute__((packed)); 106 107 struct apparmor_tags_header_v5 { 108 __u32 mask; 109 __u32 count; 110 __u32 tagset; 111 } __attribute__((packed)); 112 113 // v3 doesn't have tags but this just adds padding to the data section 114 struct apparmor_notif_file { 115 struct apparmor_notif_op base; 116 uid_t subj_uid, obj_uid; 117 __u32 name; /* offset into data */ 118 __u8 data[]; 119 } __attribute__((packed)); 120 121 struct apparmor_notif_file_v5 { 122 struct apparmor_notif_op base; 123 uid_t subj_uid, obj_uid; 124 __u32 name; /* offset into data */ 125 __u32 tags; 126 __u16 tags_count; 127 __u8 data[]; 128 } __attribute__((packed)); 129 130 /* ioctl structs */ 131 union apparmor_notif_filters { 132 struct { 133 struct apparmor_notif_common base; 134 __u32 modeset; /* which notification mode */ 135 __u32 ns; /* offset into data */ 136 __u32 filter; /* offset into data */ 137 138 __u8 data[]; 139 }; 140 /* common and defined before vX, replicates v3 */ 141 struct apparmor_notif_filter v3; 142 struct apparmor_notif_filter v5; 143 } __attribute__((packed)); 144 145 union apparmor_notif_recv { 146 /* common and defined before vX, replicates v3 */ 147 struct { 148 struct apparmor_notif_op base; 149 uid_t subj_uid, obj_uid; 150 __u32 name; /* offset into data */ 151 __u8 data[]; 152 }; 153 struct { 154 struct apparmor_notif_file file; 155 } v3; 156 struct { 157 struct apparmor_notif_file_v5 file; 158 } v5; 159 } __attribute__((packed)); 160 161 union apparmor_notif_resp { 162 /* common and defined before vX, replicates v3 */ 163 struct apparmor_notif base; 164 struct apparmor_notif_resp_perm perm; 165 struct apparmor_notif_resp_name name; 166 union { 167 struct apparmor_notif_resp_perm perm; 168 struct apparmor_notif_resp_name name; 169 } v3; 170 union { 171 struct apparmor_notif_resp_perm perm; 172 struct apparmor_notif_resp_name name; 173 } v5; 174 } __attribute__((packed)); 175 176 union apparmor_notif_register { 177 struct { 178 struct apparmor_notif_register_v5 registration; 179 struct apparmor_notif_resend_v5 resend; 180 } v5; 181 } __attribute__((packed)); 182 183 union apparmor_notif_all { 184 struct apparmor_notif_common common; 185 struct apparmor_notif base; 186 struct apparmor_notif_op op; 187 struct apparmor_notif_file filev3; 188 struct apparmor_notif_file_v5 file; 189 union apparmor_notif_filters filter; 190 union apparmor_notif_recv recv; 191 union apparmor_notif_resp respnse; 192 union apparmor_notif_register registration; 193 } __attribute__((packed)); 194 195 #define APPARMOR_IOC_MAGIC 0xF8 196 197 /* Flags for apparmor notification fd ioctl. */ 198 199 #define APPARMOR_NOTIF_SET_FILTER _IOW(APPARMOR_IOC_MAGIC, 0, \ 200 union apparmor_notif_filters *) 201 #define APPARMOR_NOTIF_GET_FILTER _IOR(APPARMOR_IOC_MAGIC, 1, \ 202 union apparmor_notif_filters *) 203 #define APPARMOR_NOTIF_IS_ID_VALID _IOR(APPARMOR_IOC_MAGIC, 3, \ 204 __u64) 205 /* RECV/SEND from userspace pov */ 206 #define APPARMOR_NOTIF_RECV _IOWR(APPARMOR_IOC_MAGIC, 4, \ 207 union apparmor_notif_recv *) 208 #define APPARMOR_NOTIF_SEND _IOWR(APPARMOR_IOC_MAGIC, 5, \ 209 union apparmor_notif_resp *) 210 #define APPARMOR_NOTIF_REGISTER _IOWR(APPARMOR_IOC_MAGIC, 6, \ 211 union apparmor_notif_register *) 212 #define APPARMOR_NOTIF_RESEND _IOWR(APPARMOR_IOC_MAGIC, 7, \ 213 union apparmor_notif_register *) 214 215 216 #endif /* _LINUX_APPARMOR_H */