Lines Matching refs:e
106 const char *name, const char *info, struct aa_ext *e, in audit_iface() argument
111 if (e) in audit_iface()
112 aad(&sa)->iface.pos = e->pos - e->start; in audit_iface()
201 static bool inbounds(struct aa_ext *e, size_t size) in inbounds() argument
203 return (size <= e->end - e->pos); in inbounds()
222 static size_t unpack_u16_chunk(struct aa_ext *e, char **chunk) in unpack_u16_chunk() argument
225 void *pos = e->pos; in unpack_u16_chunk()
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()
238 e->pos = pos; in unpack_u16_chunk()
243 static bool unpack_X(struct aa_ext *e, enum aa_code code) in unpack_X() argument
245 if (!inbounds(e, 1)) in unpack_X()
247 if (*(u8 *) e->pos != code) in unpack_X()
249 e->pos++; in unpack_X()
269 static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) in unpack_nameX() argument
274 void *pos = e->pos; in unpack_nameX()
279 if (unpack_X(e, AA_NAME)) { in unpack_nameX()
281 size_t size = unpack_u16_chunk(e, &tag); in unpack_nameX()
291 if (unpack_X(e, code)) in unpack_nameX()
295 e->pos = pos; in unpack_nameX()
299 static bool unpack_u8(struct aa_ext *e, u8 *data, const char *name) in unpack_u8() argument
301 void *pos = e->pos; in unpack_u8()
303 if (unpack_nameX(e, AA_U8, name)) { in unpack_u8()
304 if (!inbounds(e, sizeof(u8))) in unpack_u8()
307 *data = get_unaligned((u8 *)e->pos); in unpack_u8()
308 e->pos += sizeof(u8); in unpack_u8()
313 e->pos = pos; in unpack_u8()
317 static bool unpack_u32(struct aa_ext *e, u32 *data, const char *name) in unpack_u32() argument
319 void *pos = e->pos; in unpack_u32()
321 if (unpack_nameX(e, AA_U32, name)) { in unpack_u32()
322 if (!inbounds(e, sizeof(u32))) in unpack_u32()
325 *data = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in unpack_u32()
326 e->pos += sizeof(u32); in unpack_u32()
331 e->pos = pos; in unpack_u32()
335 static bool unpack_u64(struct aa_ext *e, u64 *data, const char *name) in unpack_u64() argument
337 void *pos = e->pos; in unpack_u64()
339 if (unpack_nameX(e, AA_U64, name)) { in unpack_u64()
340 if (!inbounds(e, sizeof(u64))) in unpack_u64()
343 *data = le64_to_cpu(get_unaligned((__le64 *) e->pos)); in unpack_u64()
344 e->pos += sizeof(u64); in unpack_u64()
349 e->pos = pos; in unpack_u64()
353 static size_t unpack_array(struct aa_ext *e, const char *name) in unpack_array() argument
355 void *pos = e->pos; in unpack_array()
357 if (unpack_nameX(e, AA_ARRAY, name)) { in unpack_array()
359 if (!inbounds(e, sizeof(u16))) in unpack_array()
361 size = (int)le16_to_cpu(get_unaligned((__le16 *) e->pos)); in unpack_array()
362 e->pos += sizeof(u16); in unpack_array()
367 e->pos = pos; in unpack_array()
371 static size_t unpack_blob(struct aa_ext *e, char **blob, const char *name) in unpack_blob() argument
373 void *pos = e->pos; in unpack_blob()
375 if (unpack_nameX(e, AA_BLOB, name)) { in unpack_blob()
377 if (!inbounds(e, sizeof(u32))) in unpack_blob()
379 size = le32_to_cpu(get_unaligned((__le32 *) e->pos)); in unpack_blob()
380 e->pos += sizeof(u32); in unpack_blob()
381 if (inbounds(e, (size_t) size)) { in unpack_blob()
382 *blob = e->pos; in unpack_blob()
383 e->pos += size; in unpack_blob()
389 e->pos = pos; in unpack_blob()
393 static int unpack_str(struct aa_ext *e, const char **string, const char *name) in unpack_str() argument
397 void *pos = e->pos; in unpack_str()
399 if (unpack_nameX(e, AA_STRING, name)) { in unpack_str()
400 size = unpack_u16_chunk(e, &src_str); in unpack_str()
412 e->pos = pos; in unpack_str()
416 static int unpack_strdup(struct aa_ext *e, char **string, const char *name) in unpack_strdup() argument
419 void *pos = e->pos; in unpack_strdup()
420 int res = unpack_str(e, &tmp, name); in unpack_strdup()
428 e->pos = pos; in unpack_strdup()
442 static struct aa_dfa *unpack_dfa(struct aa_ext *e) in unpack_dfa() argument
448 size = unpack_blob(e, &blob, "aadfa"); in unpack_dfa()
455 size_t sz = blob - (char *) e->start - in unpack_dfa()
456 ((e->pos - e->start) & 7); in unpack_dfa()
477 static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile) in unpack_trans_table() argument
479 void *saved_pos = e->pos; in unpack_trans_table()
482 if (unpack_nameX(e, AA_STRUCT, "xtable")) { in unpack_trans_table()
485 size = unpack_array(e, NULL); in unpack_trans_table()
497 int c, j, pos, size2 = unpack_strdup(e, &str, NULL); in unpack_trans_table()
533 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_trans_table()
535 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_trans_table()
542 e->pos = saved_pos; in unpack_trans_table()
546 static bool unpack_xattrs(struct aa_ext *e, struct aa_profile *profile) in unpack_xattrs() argument
548 void *pos = e->pos; in unpack_xattrs()
550 if (unpack_nameX(e, AA_STRUCT, "xattrs")) { in unpack_xattrs()
553 size = unpack_array(e, NULL); in unpack_xattrs()
559 if (!unpack_strdup(e, &profile->xattrs[i], NULL)) in unpack_xattrs()
562 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_xattrs()
564 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_xattrs()
571 e->pos = pos; in unpack_xattrs()
575 static bool unpack_secmark(struct aa_ext *e, struct aa_profile *profile) in unpack_secmark() argument
577 void *pos = e->pos; in unpack_secmark()
580 if (unpack_nameX(e, AA_STRUCT, "secmark")) { in unpack_secmark()
581 size = unpack_array(e, NULL); in unpack_secmark()
591 if (!unpack_u8(e, &profile->secmark[i].audit, NULL)) in unpack_secmark()
593 if (!unpack_u8(e, &profile->secmark[i].deny, NULL)) in unpack_secmark()
595 if (!unpack_strdup(e, &profile->secmark[i].label, NULL)) in unpack_secmark()
598 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_secmark()
600 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_secmark()
615 e->pos = pos; in unpack_secmark()
619 static bool unpack_rlimits(struct aa_ext *e, struct aa_profile *profile) in unpack_rlimits() argument
621 void *pos = e->pos; in unpack_rlimits()
624 if (unpack_nameX(e, AA_STRUCT, "rlimits")) { in unpack_rlimits()
627 if (!unpack_u32(e, &tmp, NULL)) in unpack_rlimits()
631 size = unpack_array(e, NULL); in unpack_rlimits()
637 if (!unpack_u64(e, &tmp2, NULL)) in unpack_rlimits()
641 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_rlimits()
643 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_rlimits()
649 e->pos = pos; in unpack_rlimits()
674 static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) in unpack_profile() argument
690 if (!unpack_nameX(e, AA_STRUCT, "profile")) in unpack_profile()
692 if (!unpack_str(e, &name, NULL)) in unpack_profile()
716 (void) unpack_str(e, &profile->rename, "rename"); in unpack_profile()
719 (void) unpack_str(e, &profile->attach, "attach"); in unpack_profile()
722 profile->xmatch = unpack_dfa(e); in unpack_profile()
731 if (!unpack_u32(e, &tmp, NULL)) { in unpack_profile()
739 (void) unpack_str(e, &profile->disconnected, "disconnected"); in unpack_profile()
742 if (!unpack_nameX(e, AA_STRUCT, "flags")) { in unpack_profile()
747 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
751 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
753 if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) { in unpack_profile()
765 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
770 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
774 if (unpack_u32(e, &profile->path_flags, "path_flags")) in unpack_profile()
782 if (!unpack_u32(e, &(profile->caps.allow.cap[0]), NULL)) in unpack_profile()
784 if (!unpack_u32(e, &(profile->caps.audit.cap[0]), NULL)) in unpack_profile()
786 if (!unpack_u32(e, &(profile->caps.quiet.cap[0]), NULL)) in unpack_profile()
788 if (!unpack_u32(e, &tmpcap.cap[0], NULL)) in unpack_profile()
792 if (unpack_nameX(e, AA_STRUCT, "caps64")) { in unpack_profile()
794 if (!unpack_u32(e, &(profile->caps.allow.cap[1]), NULL)) in unpack_profile()
796 if (!unpack_u32(e, &(profile->caps.audit.cap[1]), NULL)) in unpack_profile()
798 if (!unpack_u32(e, &(profile->caps.quiet.cap[1]), NULL)) in unpack_profile()
800 if (!unpack_u32(e, &(tmpcap.cap[1]), NULL)) in unpack_profile()
802 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
807 if (unpack_nameX(e, AA_STRUCT, "capsx")) { in unpack_profile()
809 if (!unpack_u32(e, &(profile->caps.extended.cap[0]), NULL)) in unpack_profile()
811 if (!unpack_u32(e, &(profile->caps.extended.cap[1]), NULL)) in unpack_profile()
813 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
817 if (!unpack_xattrs(e, profile)) { in unpack_profile()
822 if (!unpack_rlimits(e, profile)) { in unpack_profile()
827 if (!unpack_secmark(e, profile)) { in unpack_profile()
832 if (unpack_nameX(e, AA_STRUCT, "policydb")) { in unpack_profile()
835 profile->policy.dfa = unpack_dfa(e); in unpack_profile()
844 if (!unpack_u32(e, &profile->policy.start[0], "start")) in unpack_profile()
854 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
860 profile->file.dfa = unpack_dfa(e); in unpack_profile()
867 if (!unpack_u32(e, &profile->file.start, "dfa_start")) in unpack_profile()
877 if (!unpack_trans_table(e, profile)) { in unpack_profile()
882 if (unpack_nameX(e, AA_STRUCT, "data")) { in unpack_profile()
900 while (unpack_strdup(e, &key, NULL)) { in unpack_profile()
908 data->size = unpack_blob(e, &data->data, NULL); in unpack_profile()
925 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
931 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) { in unpack_profile()
943 audit_iface(profile, NULL, name, info, e, error); in unpack_profile()
957 static int verify_header(struct aa_ext *e, int required, const char **ns) in verify_header() argument
964 if (!unpack_u32(e, &e->version, "version")) { in verify_header()
967 e, error); in verify_header()
976 if (VERSION_LT(e->version, v5) || VERSION_GT(e->version, v8)) { in verify_header()
978 e, error); in verify_header()
983 if (unpack_str(e, &name, "namespace")) { in verify_header()
986 e, error); in verify_header()
990 audit_iface(NULL, NULL, NULL, "invalid ns change", e, in verify_header()
1180 struct aa_ext e = { in aa_unpack() local
1187 while (e.pos < e.end) { in aa_unpack()
1190 error = verify_header(&e, e.pos == e.start, ns); in aa_unpack()
1194 start = e.pos; in aa_unpack()
1195 profile = unpack_profile(&e, &ns_name); in aa_unpack()
1206 error = aa_calc_profile_hash(profile, e.version, start, in aa_unpack()
1207 e.pos - start); in aa_unpack()
1221 udata->abi = e.version & K_ABI_MASK; in aa_unpack()