Lines Matching refs:e
62 const char *name, const char *info, struct aa_ext *e, in audit_iface() argument
67 if (e) in audit_iface()
68 aad(&sa)->iface.pos = e->pos - e->start; in audit_iface()
158 VISIBLE_IF_KUNIT bool aa_inbounds(struct aa_ext *e, size_t size) in aa_inbounds() argument
160 return (size <= e->end - e->pos); in aa_inbounds()
171 VISIBLE_IF_KUNIT size_t aa_unpack_u16_chunk(struct aa_ext *e, char **chunk) in aa_unpack_u16_chunk() argument
174 void *pos = e->pos; in aa_unpack_u16_chunk()
176 if (!aa_inbounds(e, sizeof(u16))) in aa_unpack_u16_chunk()
178 size = le16_to_cpu(get_unaligned((__le16 *) e->pos)); in aa_unpack_u16_chunk()
179 e->pos += sizeof(__le16); in aa_unpack_u16_chunk()
180 if (!aa_inbounds(e, size)) in aa_unpack_u16_chunk()
182 *chunk = e->pos; in aa_unpack_u16_chunk()
183 e->pos += size; in aa_unpack_u16_chunk()
187 e->pos = pos; in aa_unpack_u16_chunk()
193 VISIBLE_IF_KUNIT bool aa_unpack_X(struct aa_ext *e, enum aa_code code) in aa_unpack_X() argument
195 if (!aa_inbounds(e, 1)) in aa_unpack_X()
197 if (*(u8 *) e->pos != code) in aa_unpack_X()
199 e->pos++; in aa_unpack_X()
220 VISIBLE_IF_KUNIT bool aa_unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) in aa_unpack_nameX() argument
225 void *pos = e->pos; in aa_unpack_nameX()
230 if (aa_unpack_X(e, AA_NAME)) { in aa_unpack_nameX()
232 size_t size = aa_unpack_u16_chunk(e, &tag); in aa_unpack_nameX()
242 if (aa_unpack_X(e, code)) in aa_unpack_nameX()
246 e->pos = pos; in aa_unpack_nameX()
251 static bool unpack_u8(struct aa_ext *e, u8 *data, const char *name) in unpack_u8() argument
253 void *pos = e->pos; in unpack_u8()
255 if (aa_unpack_nameX(e, AA_U8, name)) { in unpack_u8()
256 if (!aa_inbounds(e, sizeof(u8))) in unpack_u8()
259 *data = *((u8 *)e->pos); in unpack_u8()
260 e->pos += sizeof(u8); in unpack_u8()
265 e->pos = pos; in unpack_u8()
269 VISIBLE_IF_KUNIT bool aa_unpack_u32(struct aa_ext *e, u32 *data, const char *name) in aa_unpack_u32() argument
271 void *pos = e->pos; in aa_unpack_u32()
273 if (aa_unpack_nameX(e, AA_U32, name)) { in aa_unpack_u32()
274 if (!aa_inbounds(e, sizeof(u32))) in aa_unpack_u32()
277 *data = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in aa_unpack_u32()
278 e->pos += sizeof(u32); in aa_unpack_u32()
283 e->pos = pos; in aa_unpack_u32()
288 VISIBLE_IF_KUNIT bool aa_unpack_u64(struct aa_ext *e, u64 *data, const char *name) in aa_unpack_u64() argument
290 void *pos = e->pos; in aa_unpack_u64()
292 if (aa_unpack_nameX(e, AA_U64, name)) { in aa_unpack_u64()
293 if (!aa_inbounds(e, sizeof(u64))) in aa_unpack_u64()
296 *data = le64_to_cpu(get_unaligned((__le64 *) e->pos)); in aa_unpack_u64()
297 e->pos += sizeof(u64); in aa_unpack_u64()
302 e->pos = pos; in aa_unpack_u64()
307 static bool aa_unpack_cap_low(struct aa_ext *e, kernel_cap_t *data, const char *name) in aa_unpack_cap_low() argument
311 if (!aa_unpack_u32(e, &val, name)) in aa_unpack_cap_low()
317 static bool aa_unpack_cap_high(struct aa_ext *e, kernel_cap_t *data, const char *name) in aa_unpack_cap_high() argument
321 if (!aa_unpack_u32(e, &val, name)) in aa_unpack_cap_high()
327 VISIBLE_IF_KUNIT bool aa_unpack_array(struct aa_ext *e, const char *name, u16 *size) in aa_unpack_array() argument
329 void *pos = e->pos; in aa_unpack_array()
331 if (aa_unpack_nameX(e, AA_ARRAY, name)) { in aa_unpack_array()
332 if (!aa_inbounds(e, sizeof(u16))) in aa_unpack_array()
334 *size = le16_to_cpu(get_unaligned((__le16 *) e->pos)); in aa_unpack_array()
335 e->pos += sizeof(u16); in aa_unpack_array()
340 e->pos = pos; in aa_unpack_array()
345 VISIBLE_IF_KUNIT size_t aa_unpack_blob(struct aa_ext *e, char **blob, const char *name) in aa_unpack_blob() argument
347 void *pos = e->pos; in aa_unpack_blob()
349 if (aa_unpack_nameX(e, AA_BLOB, name)) { in aa_unpack_blob()
351 if (!aa_inbounds(e, sizeof(u32))) in aa_unpack_blob()
353 size = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in aa_unpack_blob()
354 e->pos += sizeof(u32); in aa_unpack_blob()
355 if (aa_inbounds(e, (size_t) size)) { in aa_unpack_blob()
356 *blob = e->pos; in aa_unpack_blob()
357 e->pos += size; in aa_unpack_blob()
363 e->pos = pos; in aa_unpack_blob()
368 VISIBLE_IF_KUNIT int aa_unpack_str(struct aa_ext *e, const char **string, const char *name) in aa_unpack_str() argument
372 void *pos = e->pos; in aa_unpack_str()
374 if (aa_unpack_nameX(e, AA_STRING, name)) { in aa_unpack_str()
375 size = aa_unpack_u16_chunk(e, &src_str); in aa_unpack_str()
387 e->pos = pos; in aa_unpack_str()
392 VISIBLE_IF_KUNIT int aa_unpack_strdup(struct aa_ext *e, char **string, const char *name) in aa_unpack_strdup() argument
395 void *pos = e->pos; in aa_unpack_strdup()
396 int res = aa_unpack_str(e, &tmp, name); in aa_unpack_strdup()
404 e->pos = pos; in aa_unpack_strdup()
420 static struct aa_dfa *unpack_dfa(struct aa_ext *e, int flags) in unpack_dfa() argument
426 size = aa_unpack_blob(e, &blob, "aadfa"); in unpack_dfa()
433 size_t sz = blob - (char *) e->start - in unpack_dfa()
434 ((e->pos - e->start) & 7); in unpack_dfa()
455 static bool unpack_trans_table(struct aa_ext *e, struct aa_str_table *strs) in unpack_trans_table() argument
457 void *saved_pos = e->pos; in unpack_trans_table()
461 if (aa_unpack_nameX(e, AA_STRUCT, "xtable")) { in unpack_trans_table()
465 if (!aa_unpack_array(e, NULL, &size)) in unpack_trans_table()
479 int c, j, pos, size2 = aa_unpack_strdup(e, &str, NULL); in unpack_trans_table()
515 if (!aa_unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_trans_table()
517 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_trans_table()
527 e->pos = saved_pos; in unpack_trans_table()
531 static bool unpack_xattrs(struct aa_ext *e, struct aa_profile *profile) in unpack_xattrs() argument
533 void *pos = e->pos; in unpack_xattrs()
535 if (aa_unpack_nameX(e, AA_STRUCT, "xattrs")) { in unpack_xattrs()
539 if (!aa_unpack_array(e, NULL, &size)) in unpack_xattrs()
546 if (!aa_unpack_strdup(e, &profile->attach.xattrs[i], NULL)) in unpack_xattrs()
549 if (!aa_unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_xattrs()
551 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_xattrs()
558 e->pos = pos; in unpack_xattrs()
562 static bool unpack_secmark(struct aa_ext *e, struct aa_ruleset *rules) in unpack_secmark() argument
564 void *pos = e->pos; in unpack_secmark()
568 if (aa_unpack_nameX(e, AA_STRUCT, "secmark")) { in unpack_secmark()
569 if (!aa_unpack_array(e, NULL, &size)) in unpack_secmark()
580 if (!unpack_u8(e, &rules->secmark[i].audit, NULL)) in unpack_secmark()
582 if (!unpack_u8(e, &rules->secmark[i].deny, NULL)) in unpack_secmark()
584 if (!aa_unpack_strdup(e, &rules->secmark[i].label, NULL)) in unpack_secmark()
587 if (!aa_unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_secmark()
589 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_secmark()
604 e->pos = pos; in unpack_secmark()
608 static bool unpack_rlimits(struct aa_ext *e, struct aa_ruleset *rules) in unpack_rlimits() argument
610 void *pos = e->pos; in unpack_rlimits()
613 if (aa_unpack_nameX(e, AA_STRUCT, "rlimits")) { in unpack_rlimits()
617 if (!aa_unpack_u32(e, &tmp, NULL)) in unpack_rlimits()
621 if (!aa_unpack_array(e, NULL, &size) || in unpack_rlimits()
627 if (!aa_unpack_u64(e, &tmp2, NULL)) in unpack_rlimits()
631 if (!aa_unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_rlimits()
633 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_rlimits()
639 e->pos = pos; in unpack_rlimits()
643 static bool unpack_perm(struct aa_ext *e, u32 version, struct aa_perms *perm) in unpack_perm() argument
648 return aa_unpack_u32(e, &perm->allow, NULL) && in unpack_perm()
649 aa_unpack_u32(e, &perm->allow, NULL) && in unpack_perm()
650 aa_unpack_u32(e, &perm->deny, NULL) && in unpack_perm()
651 aa_unpack_u32(e, &perm->subtree, NULL) && in unpack_perm()
652 aa_unpack_u32(e, &perm->cond, NULL) && in unpack_perm()
653 aa_unpack_u32(e, &perm->kill, NULL) && in unpack_perm()
654 aa_unpack_u32(e, &perm->complain, NULL) && in unpack_perm()
655 aa_unpack_u32(e, &perm->prompt, NULL) && in unpack_perm()
656 aa_unpack_u32(e, &perm->audit, NULL) && in unpack_perm()
657 aa_unpack_u32(e, &perm->quiet, NULL) && in unpack_perm()
658 aa_unpack_u32(e, &perm->hide, NULL) && in unpack_perm()
659 aa_unpack_u32(e, &perm->xindex, NULL) && in unpack_perm()
660 aa_unpack_u32(e, &perm->tag, NULL) && in unpack_perm()
661 aa_unpack_u32(e, &perm->label, NULL); in unpack_perm()
664 static ssize_t unpack_perms_table(struct aa_ext *e, struct aa_perms **perms) in unpack_perms_table() argument
666 void *pos = e->pos; in unpack_perms_table()
674 if (aa_unpack_nameX(e, AA_STRUCT, "perms")) { in unpack_perms_table()
678 if (!aa_unpack_u32(e, &version, "version")) in unpack_perms_table()
680 if (!aa_unpack_array(e, NULL, &size)) in unpack_perms_table()
686 if (!unpack_perm(e, version, &(*perms)[i])) in unpack_perms_table()
689 if (!aa_unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_perms_table()
691 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_perms_table()
701 e->pos = pos; in unpack_perms_table()
705 static int unpack_pdb(struct aa_ext *e, struct aa_policydb *policy, in unpack_pdb() argument
709 void *pos = e->pos; in unpack_pdb()
713 size = unpack_perms_table(e, &policy->perms); in unpack_pdb()
731 policy->dfa = unpack_dfa(e, flags); in unpack_pdb()
751 if (!aa_unpack_u32(e, &policy->start[0], "start")) in unpack_pdb()
754 if (!aa_unpack_u32(e, &policy->start[AA_CLASS_FILE], "dfa_start")) { in unpack_pdb()
762 if (!unpack_trans_table(e, &policy->trans) && required_trans) { in unpack_pdb()
773 e->pos = pos; in unpack_pdb()
799 static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) in unpack_profile() argument
816 if (!aa_unpack_nameX(e, AA_STRUCT, "profile")) in unpack_profile()
818 if (!aa_unpack_str(e, &name, NULL)) in unpack_profile()
843 (void) aa_unpack_str(e, &profile->rename, "rename"); in unpack_profile()
846 (void) aa_unpack_str(e, &profile->attach.xmatch_str, "attach"); in unpack_profile()
849 error = unpack_pdb(e, &profile->attach.xmatch, false, false, &info); in unpack_profile()
857 if (!aa_unpack_u32(e, &tmp, NULL)) { in unpack_profile()
871 (void) aa_unpack_str(e, &profile->disconnected, "disconnected"); in unpack_profile()
874 if (!aa_unpack_nameX(e, AA_STRUCT, "flags")) { in unpack_profile()
879 if (!aa_unpack_u32(e, &tmp, NULL)) in unpack_profile()
887 if (!aa_unpack_u32(e, &tmp, NULL)) in unpack_profile()
889 if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) { in unpack_profile()
903 if (!aa_unpack_u32(e, &tmp, NULL)) in unpack_profile()
908 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
912 if (aa_unpack_u32(e, &profile->path_flags, "path_flags")) in unpack_profile()
920 if (!aa_unpack_cap_low(e, &rules->caps.allow, NULL)) in unpack_profile()
922 if (!aa_unpack_cap_low(e, &rules->caps.audit, NULL)) in unpack_profile()
924 if (!aa_unpack_cap_low(e, &rules->caps.quiet, NULL)) in unpack_profile()
926 if (!aa_unpack_cap_low(e, &tmpcap, NULL)) in unpack_profile()
930 if (aa_unpack_nameX(e, AA_STRUCT, "caps64")) { in unpack_profile()
932 if (!aa_unpack_cap_high(e, &rules->caps.allow, NULL)) in unpack_profile()
934 if (!aa_unpack_cap_high(e, &rules->caps.audit, NULL)) in unpack_profile()
936 if (!aa_unpack_cap_high(e, &rules->caps.quiet, NULL)) in unpack_profile()
938 if (!aa_unpack_cap_high(e, &tmpcap, NULL)) in unpack_profile()
940 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
945 if (aa_unpack_nameX(e, AA_STRUCT, "capsx")) { in unpack_profile()
947 if (!aa_unpack_cap_low(e, &rules->caps.extended, NULL)) in unpack_profile()
949 if (!aa_unpack_cap_high(e, &rules->caps.extended, NULL)) in unpack_profile()
951 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
955 if (!unpack_xattrs(e, profile)) { in unpack_profile()
960 if (!unpack_rlimits(e, rules)) { in unpack_profile()
965 if (!unpack_secmark(e, rules)) { in unpack_profile()
970 if (aa_unpack_nameX(e, AA_STRUCT, "policydb")) { in unpack_profile()
973 error = unpack_pdb(e, &rules->policy, true, false, in unpack_profile()
984 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
986 error = aa_compat_map_policy(&rules->policy, e->version); in unpack_profile()
995 error = unpack_pdb(e, &rules->file, false, true, &info); in unpack_profile()
1012 if (aa_unpack_nameX(e, AA_STRUCT, "data")) { in unpack_profile()
1031 while (aa_unpack_strdup(e, &key, NULL)) { in unpack_profile()
1040 data->size = aa_unpack_blob(e, &data->data, NULL); in unpack_profile()
1053 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
1059 if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
1078 audit_iface(profile, NULL, name, info, e, error); in unpack_profile()
1092 static int verify_header(struct aa_ext *e, int required, const char **ns) in verify_header() argument
1099 if (!aa_unpack_u32(e, &e->version, "version")) { in verify_header()
1102 e, error); in verify_header()
1111 if (VERSION_LT(e->version, v5) || VERSION_GT(e->version, v9)) { in verify_header()
1113 e, error); in verify_header()
1118 if (aa_unpack_str(e, &name, "namespace")) { in verify_header()
1121 e, error); in verify_header()
1125 audit_iface(NULL, NULL, NULL, "invalid ns change", e, in verify_header()
1378 struct aa_ext e = { in aa_unpack() local
1385 while (e.pos < e.end) { in aa_unpack()
1387 error = verify_header(&e, e.pos == e.start, ns); in aa_unpack()
1391 start = e.pos; in aa_unpack()
1392 profile = unpack_profile(&e, &ns_name); in aa_unpack()
1403 error = aa_calc_profile_hash(profile, e.version, start, in aa_unpack()
1404 e.pos - start); in aa_unpack()
1419 udata->abi = e.version & K_ABI_MASK; in aa_unpack()