Lines Matching refs:e

93 		       const char *info, struct aa_ext *e, int error)  in audit_iface()  argument
100 if (e) in audit_iface()
101 aad.iface.pos = e->pos - e->start; in audit_iface()
112 static bool inbounds(struct aa_ext *e, size_t size) in inbounds() argument
114 return (size <= e->end - e->pos); in inbounds()
124 static size_t unpack_u16_chunk(struct aa_ext *e, char **chunk) in unpack_u16_chunk() argument
128 if (!inbounds(e, sizeof(u16))) in unpack_u16_chunk()
130 size = le16_to_cpu(get_unaligned((u16 *) e->pos)); in unpack_u16_chunk()
131 e->pos += sizeof(u16); in unpack_u16_chunk()
132 if (!inbounds(e, size)) in unpack_u16_chunk()
134 *chunk = e->pos; in unpack_u16_chunk()
135 e->pos += size; in unpack_u16_chunk()
140 static bool unpack_X(struct aa_ext *e, enum aa_code code) in unpack_X() argument
142 if (!inbounds(e, 1)) in unpack_X()
144 if (*(u8 *) e->pos != code) in unpack_X()
146 e->pos++; in unpack_X()
166 static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) in unpack_nameX() argument
171 void *pos = e->pos; in unpack_nameX()
176 if (unpack_X(e, AA_NAME)) { in unpack_nameX()
178 size_t size = unpack_u16_chunk(e, &tag); in unpack_nameX()
188 if (unpack_X(e, code)) in unpack_nameX()
192 e->pos = pos; in unpack_nameX()
196 static bool unpack_u32(struct aa_ext *e, u32 *data, const char *name) in unpack_u32() argument
198 if (unpack_nameX(e, AA_U32, name)) { in unpack_u32()
199 if (!inbounds(e, sizeof(u32))) in unpack_u32()
202 *data = le32_to_cpu(get_unaligned((u32 *) e->pos)); in unpack_u32()
203 e->pos += sizeof(u32); in unpack_u32()
209 static bool unpack_u64(struct aa_ext *e, u64 *data, const char *name) in unpack_u64() argument
211 if (unpack_nameX(e, AA_U64, name)) { in unpack_u64()
212 if (!inbounds(e, sizeof(u64))) in unpack_u64()
215 *data = le64_to_cpu(get_unaligned((u64 *) e->pos)); in unpack_u64()
216 e->pos += sizeof(u64); in unpack_u64()
222 static size_t unpack_array(struct aa_ext *e, const char *name) in unpack_array() argument
224 if (unpack_nameX(e, AA_ARRAY, name)) { in unpack_array()
226 if (!inbounds(e, sizeof(u16))) in unpack_array()
228 size = (int)le16_to_cpu(get_unaligned((u16 *) e->pos)); in unpack_array()
229 e->pos += sizeof(u16); in unpack_array()
235 static size_t unpack_blob(struct aa_ext *e, char **blob, const char *name) in unpack_blob() argument
237 if (unpack_nameX(e, AA_BLOB, name)) { in unpack_blob()
239 if (!inbounds(e, sizeof(u32))) in unpack_blob()
241 size = le32_to_cpu(get_unaligned((u32 *) e->pos)); in unpack_blob()
242 e->pos += sizeof(u32); in unpack_blob()
243 if (inbounds(e, (size_t) size)) { in unpack_blob()
244 *blob = e->pos; in unpack_blob()
245 e->pos += size; in unpack_blob()
252 static int unpack_str(struct aa_ext *e, const char **string, const char *name) in unpack_str() argument
256 void *pos = e->pos; in unpack_str()
258 if (unpack_nameX(e, AA_STRING, name)) { in unpack_str()
259 size = unpack_u16_chunk(e, &src_str); in unpack_str()
270 e->pos = pos; in unpack_str()
274 static int unpack_strdup(struct aa_ext *e, char **string, const char *name) in unpack_strdup() argument
277 void *pos = e->pos; in unpack_strdup()
278 int res = unpack_str(e, &tmp, name); in unpack_strdup()
286 e->pos = pos; in unpack_strdup()
326 static struct aa_dfa *unpack_dfa(struct aa_ext *e) in unpack_dfa() argument
332 size = unpack_blob(e, &blob, "aadfa"); in unpack_dfa()
339 size_t sz = blob - (char *) e->start - in unpack_dfa()
340 ((e->pos - e->start) & 7); in unpack_dfa()
372 static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile) in unpack_trans_table() argument
374 void *pos = e->pos; in unpack_trans_table()
377 if (unpack_nameX(e, AA_STRUCT, "xtable")) { in unpack_trans_table()
380 size = unpack_array(e, NULL); in unpack_trans_table()
392 int c, j, size2 = unpack_strdup(e, &str, NULL); in unpack_trans_table()
422 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_trans_table()
424 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_trans_table()
431 e->pos = pos; in unpack_trans_table()
435 static bool unpack_rlimits(struct aa_ext *e, struct aa_profile *profile) in unpack_rlimits() argument
437 void *pos = e->pos; in unpack_rlimits()
440 if (unpack_nameX(e, AA_STRUCT, "rlimits")) { in unpack_rlimits()
443 if (!unpack_u32(e, &tmp, NULL)) in unpack_rlimits()
447 size = unpack_array(e, NULL); in unpack_rlimits()
453 if (!unpack_u64(e, &tmp2, NULL)) in unpack_rlimits()
457 if (!unpack_nameX(e, AA_ARRAYEND, NULL)) in unpack_rlimits()
459 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_rlimits()
465 e->pos = pos; in unpack_rlimits()
475 static struct aa_profile *unpack_profile(struct aa_ext *e) in unpack_profile() argument
484 if (!unpack_nameX(e, AA_STRUCT, "profile")) in unpack_profile()
486 if (!unpack_str(e, &name, NULL)) in unpack_profile()
494 (void) unpack_str(e, &profile->rename, "rename"); in unpack_profile()
497 (void) unpack_str(e, &profile->attach, "attach"); in unpack_profile()
500 profile->xmatch = unpack_dfa(e); in unpack_profile()
508 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
514 if (!unpack_nameX(e, AA_STRUCT, "flags")) in unpack_profile()
516 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
520 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
528 if (!unpack_u32(e, &tmp, NULL)) in unpack_profile()
533 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
537 if (unpack_u32(e, &profile->path_flags, "path_flags")) in unpack_profile()
543 if (!unpack_u32(e, &(profile->caps.allow.cap[0]), NULL)) in unpack_profile()
545 if (!unpack_u32(e, &(profile->caps.audit.cap[0]), NULL)) in unpack_profile()
547 if (!unpack_u32(e, &(profile->caps.quiet.cap[0]), NULL)) in unpack_profile()
549 if (!unpack_u32(e, &tmpcap.cap[0], NULL)) in unpack_profile()
552 if (unpack_nameX(e, AA_STRUCT, "caps64")) { in unpack_profile()
554 if (!unpack_u32(e, &(profile->caps.allow.cap[1]), NULL)) in unpack_profile()
556 if (!unpack_u32(e, &(profile->caps.audit.cap[1]), NULL)) in unpack_profile()
558 if (!unpack_u32(e, &(profile->caps.quiet.cap[1]), NULL)) in unpack_profile()
560 if (!unpack_u32(e, &(tmpcap.cap[1]), NULL)) in unpack_profile()
562 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
566 if (unpack_nameX(e, AA_STRUCT, "capsx")) { in unpack_profile()
568 if (!unpack_u32(e, &(profile->caps.extended.cap[0]), NULL)) in unpack_profile()
570 if (!unpack_u32(e, &(profile->caps.extended.cap[1]), NULL)) in unpack_profile()
572 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
576 if (!unpack_rlimits(e, profile)) in unpack_profile()
579 if (unpack_nameX(e, AA_STRUCT, "policydb")) { in unpack_profile()
581 profile->policy.dfa = unpack_dfa(e); in unpack_profile()
587 if (!unpack_u32(e, &profile->policy.start[0], "start")) in unpack_profile()
597 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
602 profile->file.dfa = unpack_dfa(e); in unpack_profile()
609 if (!unpack_u32(e, &profile->file.start, "dfa_start")) in unpack_profile()
613 if (!unpack_trans_table(e, profile)) in unpack_profile()
616 if (!unpack_nameX(e, AA_STRUCTEND, NULL)) in unpack_profile()
626 audit_iface(profile, name, "failed to unpack profile", e, error); in unpack_profile()
640 static int verify_header(struct aa_ext *e, int required, const char **ns) in verify_header() argument
647 if (!unpack_u32(e, &e->version, "version")) { in verify_header()
649 audit_iface(NULL, NULL, "invalid profile format", e, in verify_header()
655 if (e->version != 5) { in verify_header()
657 e, error); in verify_header()
664 if (unpack_str(e, &name, "namespace")) { in verify_header()
666 audit_iface(NULL, NULL, "invalid ns change", e, error); in verify_header()
754 struct aa_ext e = { in aa_unpack() local
761 while (e.pos < e.end) { in aa_unpack()
763 error = verify_header(&e, e.pos == e.start, ns); in aa_unpack()
767 start = e.pos; in aa_unpack()
768 profile = unpack_profile(&e); in aa_unpack()
778 error = aa_calc_profile_hash(profile, e.version, start, in aa_unpack()
779 e.pos - start); in aa_unpack()