Lines Matching refs:e
109 const char *name, const char *info, struct aa_ext *e, in audit_iface() argument
114 if (e) in audit_iface()
115 aad(&sa)->iface.pos = e->pos - e->start; in audit_iface()
202 static bool inbounds(struct aa_ext *e, size_t size) in inbounds() argument
204 return (size <= e->end - e->pos); in inbounds()
223 static size_t unpack_u16_chunk(struct aa_ext *e, char **chunk) in unpack_u16_chunk() argument
227 if (!inbounds(e, sizeof(u16))) in unpack_u16_chunk()
229 size = le16_to_cpu(get_unaligned((__le16 *) e->pos)); in unpack_u16_chunk()
230 e->pos += sizeof(__le16); in unpack_u16_chunk()
231 if (!inbounds(e, size)) in unpack_u16_chunk()
233 *chunk = e->pos; in unpack_u16_chunk()
234 e->pos += size; in unpack_u16_chunk()
239 static bool unpack_X(struct aa_ext *e, enum aa_code code) in unpack_X() argument
241 if (!inbounds(e, 1)) in unpack_X()
243 if (*(u8 *) e->pos != code) in unpack_X()
245 e->pos++; in unpack_X()
265 static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) in unpack_nameX() argument
270 void *pos = e->pos; in unpack_nameX()
275 if (unpack_X(e, AA_NAME)) { in unpack_nameX()
277 size_t size = unpack_u16_chunk(e, &tag); in unpack_nameX()
287 if (unpack_X(e, code)) in unpack_nameX()
291 e->pos = pos; in unpack_nameX()
295 static bool unpack_u32(struct aa_ext *e, u32 *data, const char *name) in unpack_u32() argument
297 if (unpack_nameX(e, AA_U32, name)) { in unpack_u32()
298 if (!inbounds(e, sizeof(u32))) in unpack_u32()
301 *data = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in unpack_u32()
302 e->pos += sizeof(u32); in unpack_u32()
308 static bool unpack_u64(struct aa_ext *e, u64 *data, const char *name) in unpack_u64() argument
310 if (unpack_nameX(e, AA_U64, name)) { in unpack_u64()
311 if (!inbounds(e, sizeof(u64))) in unpack_u64()
314 *data = le64_to_cpu(get_unaligned((__le64 *) e->pos)); in unpack_u64()
315 e->pos += sizeof(u64); in unpack_u64()
321 static size_t unpack_array(struct aa_ext *e, const char *name) in unpack_array() argument
323 if (unpack_nameX(e, AA_ARRAY, name)) { in unpack_array()
325 if (!inbounds(e, sizeof(u16))) in unpack_array()
327 size = (int)le16_to_cpu(get_unaligned((__le16 *) e->pos)); in unpack_array()
328 e->pos += sizeof(u16); in unpack_array()
334 static size_t unpack_blob(struct aa_ext *e, char **blob, const char *name) in unpack_blob() argument
336 if (unpack_nameX(e, AA_BLOB, name)) { in unpack_blob()
338 if (!inbounds(e, sizeof(u32))) in unpack_blob()
340 size = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in unpack_blob()
341 e->pos += sizeof(u32); in unpack_blob()
342 if (inbounds(e, (size_t) size)) { in unpack_blob()
343 *blob = e->pos; in unpack_blob()
344 e->pos += size; in unpack_blob()
351 static int unpack_str(struct aa_ext *e, const char **string, const char *name) in unpack_str() argument
355 void *pos = e->pos; in unpack_str()
357 if (unpack_nameX(e, AA_STRING, name)) { in unpack_str()
358 size = unpack_u16_chunk(e, &src_str); in unpack_str()
369 e->pos = pos; in unpack_str()
373 static int unpack_strdup(struct aa_ext *e, char **string, const char *name) in unpack_strdup() argument
376 void *pos = e->pos; in unpack_strdup()
377 int res = unpack_str(e, &tmp, name); in unpack_strdup()
385 e->pos = pos; in unpack_strdup()
399 static struct aa_dfa *unpack_dfa(struct aa_ext *e) in unpack_dfa() argument
405 size = unpack_blob(e, &blob, "aadfa"); in unpack_dfa()
412 size_t sz = blob - (char *) e->start - in unpack_dfa()
413 ((e->pos - e->start) & 7); in unpack_dfa()
434 static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile) in unpack_trans_table() argument
436 void *saved_pos = e->pos; in unpack_trans_table()
439 if (unpack_nameX(e, AA_STRUCT, "xtable")) { in unpack_trans_table()
442 size = unpack_array(e, NULL); in unpack_trans_table()
454 int c, j, pos, size2 = unpack_strdup(e, &str, NULL); in unpack_trans_table()
490 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_trans_table()
492 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_trans_table()
499 e->pos = saved_pos; in unpack_trans_table()
503 static bool unpack_xattrs(struct aa_ext *e, struct aa_profile *profile) in unpack_xattrs() argument
505 void *pos = e->pos; in unpack_xattrs()
507 if (unpack_nameX(e, AA_STRUCT, "xattrs")) { in unpack_xattrs()
510 size = unpack_array(e, NULL); in unpack_xattrs()
516 if (!unpack_strdup(e, &profile->xattrs[i], NULL)) in unpack_xattrs()
519 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_xattrs()
521 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_xattrs()
528 e->pos = pos; in unpack_xattrs()
532 static bool unpack_rlimits(struct aa_ext *e, struct aa_profile *profile) in unpack_rlimits() argument
534 void *pos = e->pos; in unpack_rlimits()
537 if (unpack_nameX(e, AA_STRUCT, "rlimits")) { in unpack_rlimits()
540 if (!unpack_u32(e, &tmp, NULL)) in unpack_rlimits()
544 size = unpack_array(e, NULL); in unpack_rlimits()
550 if (!unpack_u64(e, &tmp2, NULL)) in unpack_rlimits()
554 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_rlimits()
556 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_rlimits()
562 e->pos = pos; in unpack_rlimits()
587 static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) in unpack_profile() argument
603 if (!unpack_nameX(e, AA_STRUCT, "profile")) in unpack_profile()
605 if (!unpack_str(e, &name, NULL)) in unpack_profile()
625 (void) unpack_str(e, &profile->rename, "rename"); in unpack_profile()
628 (void) unpack_str(e, &profile->attach, "attach"); in unpack_profile()
631 profile->xmatch = unpack_dfa(e); in unpack_profile()
640 if (!unpack_u32(e, &tmp, NULL)) { in unpack_profile()
648 (void) unpack_str(e, &profile->disconnected, "disconnected"); in unpack_profile()
651 if (!unpack_nameX(e, AA_STRUCT, "flags")) { in unpack_profile()
656 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
660 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
662 if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) in unpack_profile()
668 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
673 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
677 if (unpack_u32(e, &profile->path_flags, "path_flags")) in unpack_profile()
685 if (!unpack_u32(e, &(profile->caps.allow.cap[0]), NULL)) in unpack_profile()
687 if (!unpack_u32(e, &(profile->caps.audit.cap[0]), NULL)) in unpack_profile()
689 if (!unpack_u32(e, &(profile->caps.quiet.cap[0]), NULL)) in unpack_profile()
691 if (!unpack_u32(e, &tmpcap.cap[0], NULL)) in unpack_profile()
695 if (unpack_nameX(e, AA_STRUCT, "caps64")) { in unpack_profile()
697 if (!unpack_u32(e, &(profile->caps.allow.cap[1]), NULL)) in unpack_profile()
699 if (!unpack_u32(e, &(profile->caps.audit.cap[1]), NULL)) in unpack_profile()
701 if (!unpack_u32(e, &(profile->caps.quiet.cap[1]), NULL)) in unpack_profile()
703 if (!unpack_u32(e, &(tmpcap.cap[1]), NULL)) in unpack_profile()
705 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
710 if (unpack_nameX(e, AA_STRUCT, "capsx")) { in unpack_profile()
712 if (!unpack_u32(e, &(profile->caps.extended.cap[0]), NULL)) in unpack_profile()
714 if (!unpack_u32(e, &(profile->caps.extended.cap[1]), NULL)) in unpack_profile()
716 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
720 if (!unpack_xattrs(e, profile)) { in unpack_profile()
725 if (!unpack_rlimits(e, profile)) { in unpack_profile()
730 if (unpack_nameX(e, AA_STRUCT, "policydb")) { in unpack_profile()
733 profile->policy.dfa = unpack_dfa(e); in unpack_profile()
742 if (!unpack_u32(e, &profile->policy.start[0], "start")) in unpack_profile()
752 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
758 profile->file.dfa = unpack_dfa(e); in unpack_profile()
765 if (!unpack_u32(e, &profile->file.start, "dfa_start")) in unpack_profile()
775 if (!unpack_trans_table(e, profile)) { in unpack_profile()
780 if (unpack_nameX(e, AA_STRUCT, "data")) { in unpack_profile()
798 while (unpack_strdup(e, &key, NULL)) { in unpack_profile()
806 data->size = unpack_blob(e, &data->data, NULL); in unpack_profile()
818 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
824 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
836 audit_iface(profile, NULL, name, info, e, error); in unpack_profile()
850 static int verify_header(struct aa_ext *e, int required, const char **ns) in verify_header() argument
857 if (!unpack_u32(e, &e->version, "version")) { in verify_header()
860 e, error); in verify_header()
869 if (VERSION_LT(e->version, v5) || VERSION_GT(e->version, v7)) { in verify_header()
871 e, error); in verify_header()
876 if (unpack_str(e, &name, "namespace")) { in verify_header()
879 e, error); in verify_header()
883 audit_iface(NULL, NULL, NULL, "invalid ns change", e, in verify_header()
971 struct aa_ext e = { in aa_unpack() local
978 while (e.pos < e.end) { in aa_unpack()
981 error = verify_header(&e, e.pos == e.start, ns); in aa_unpack()
985 start = e.pos; in aa_unpack()
986 profile = unpack_profile(&e, &ns_name); in aa_unpack()
997 error = aa_calc_profile_hash(profile, e.version, start, in aa_unpack()
998 e.pos - start); in aa_unpack()
1012 udata->abi = e.version & K_ABI_MASK; in aa_unpack()