• Home
  • Raw
  • Download

Lines Matching refs:p

184 static int perm_destroy(void *key, void *datum, void *p)  in perm_destroy()  argument
191 static int common_destroy(void *key, void *datum, void *p) in common_destroy() argument
218 static int cls_destroy(void *key, void *datum, void *p) in cls_destroy() argument
260 static int role_destroy(void *key, void *datum, void *p) in role_destroy() argument
274 static int type_destroy(void *key, void *datum, void *p) in type_destroy() argument
281 static int user_destroy(void *key, void *datum, void *p) in user_destroy() argument
297 static int sens_destroy(void *key, void *datum, void *p) in sens_destroy() argument
312 static int cat_destroy(void *key, void *datum, void *p) in cat_destroy() argument
331 static int filenametr_destroy(void *key, void *datum, void *p) in filenametr_destroy() argument
348 static int range_tr_destroy(void *key, void *datum, void *p) in range_tr_destroy() argument
360 static int role_tr_destroy(void *key, void *datum, void *p) in role_tr_destroy() argument
383 static int roles_init(struct policydb *p) in roles_init() argument
394 role->value = ++p->p_roles.nprim; in roles_init()
403 rc = symtab_insert(&p->p_roles, key, role); in roles_init()
453 struct policydb *p, struct filename_trans_key *key) in policydb_filenametr_search() argument
455 return hashtab_search(&p->filename_trans, key, filenametr_key_params); in policydb_filenametr_search()
489 struct mls_range *policydb_rangetr_search(struct policydb *p, in policydb_rangetr_search() argument
492 return hashtab_search(&p->range_tr, key, rangetr_key_params); in policydb_rangetr_search()
523 struct role_trans_datum *policydb_roletr_search(struct policydb *p, in policydb_roletr_search() argument
526 return hashtab_search(&p->role_tr, key, roletr_key_params); in policydb_roletr_search()
532 static void policydb_init(struct policydb *p) in policydb_init() argument
534 memset(p, 0, sizeof(*p)); in policydb_init()
536 avtab_init(&p->te_avtab); in policydb_init()
537 cond_policydb_init(p); in policydb_init()
539 ebitmap_init(&p->filename_trans_ttypes); in policydb_init()
540 ebitmap_init(&p->policycaps); in policydb_init()
541 ebitmap_init(&p->permissive_map); in policydb_init()
556 struct policydb *p; in common_index() local
560 p = datap; in common_index()
561 if (!comdatum->value || comdatum->value > p->p_commons.nprim) in common_index()
564 p->sym_val_to_name[SYM_COMMONS][comdatum->value - 1] = key; in common_index()
571 struct policydb *p; in class_index() local
575 p = datap; in class_index()
576 if (!cladatum->value || cladatum->value > p->p_classes.nprim) in class_index()
579 p->sym_val_to_name[SYM_CLASSES][cladatum->value - 1] = key; in class_index()
580 p->class_val_to_struct[cladatum->value - 1] = cladatum; in class_index()
586 struct policydb *p; in role_index() local
590 p = datap; in role_index()
592 || role->value > p->p_roles.nprim in role_index()
593 || role->bounds > p->p_roles.nprim) in role_index()
596 p->sym_val_to_name[SYM_ROLES][role->value - 1] = key; in role_index()
597 p->role_val_to_struct[role->value - 1] = role; in role_index()
603 struct policydb *p; in type_index() local
607 p = datap; in type_index()
611 || typdatum->value > p->p_types.nprim in type_index()
612 || typdatum->bounds > p->p_types.nprim) in type_index()
614 p->sym_val_to_name[SYM_TYPES][typdatum->value - 1] = key; in type_index()
615 p->type_val_to_struct[typdatum->value - 1] = typdatum; in type_index()
623 struct policydb *p; in user_index() local
627 p = datap; in user_index()
629 || usrdatum->value > p->p_users.nprim in user_index()
630 || usrdatum->bounds > p->p_users.nprim) in user_index()
633 p->sym_val_to_name[SYM_USERS][usrdatum->value - 1] = key; in user_index()
634 p->user_val_to_struct[usrdatum->value - 1] = usrdatum; in user_index()
640 struct policydb *p; in sens_index() local
644 p = datap; in sens_index()
648 levdatum->level->sens > p->p_levels.nprim) in sens_index()
651 p->sym_val_to_name[SYM_LEVELS][levdatum->level->sens - 1] = key; in sens_index()
659 struct policydb *p; in cat_index() local
663 p = datap; in cat_index()
666 if (!catdatum->value || catdatum->value > p->p_cats.nprim) in cat_index()
669 p->sym_val_to_name[SYM_CATS][catdatum->value - 1] = key; in cat_index()
718 static int policydb_index(struct policydb *p) in policydb_index() argument
722 if (p->mls_enabled) in policydb_index()
724 p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, in policydb_index()
725 p->p_bools.nprim, p->p_levels.nprim, p->p_cats.nprim); in policydb_index()
728 p->p_users.nprim, p->p_roles.nprim, p->p_types.nprim, in policydb_index()
729 p->p_bools.nprim); in policydb_index()
732 p->p_classes.nprim, p->te_avtab.nel); in policydb_index()
735 avtab_hash_eval(&p->te_avtab, "rules"); in policydb_index()
736 symtab_hash_eval(p->symtab); in policydb_index()
739 p->class_val_to_struct = kcalloc(p->p_classes.nprim, in policydb_index()
740 sizeof(*p->class_val_to_struct), in policydb_index()
742 if (!p->class_val_to_struct) in policydb_index()
745 p->role_val_to_struct = kcalloc(p->p_roles.nprim, in policydb_index()
746 sizeof(*p->role_val_to_struct), in policydb_index()
748 if (!p->role_val_to_struct) in policydb_index()
751 p->user_val_to_struct = kcalloc(p->p_users.nprim, in policydb_index()
752 sizeof(*p->user_val_to_struct), in policydb_index()
754 if (!p->user_val_to_struct) in policydb_index()
757 p->type_val_to_struct = kvcalloc(p->p_types.nprim, in policydb_index()
758 sizeof(*p->type_val_to_struct), in policydb_index()
760 if (!p->type_val_to_struct) in policydb_index()
763 rc = cond_init_bool_indexes(p); in policydb_index()
768 p->sym_val_to_name[i] = kvcalloc(p->symtab[i].nprim, in policydb_index()
771 if (!p->sym_val_to_name[i]) in policydb_index()
774 rc = hashtab_map(&p->symtab[i].table, index_f[i], p); in policydb_index()
786 void policydb_destroy(struct policydb *p) in policydb_destroy() argument
795 hashtab_map(&p->symtab[i].table, destroy_f[i], NULL); in policydb_destroy()
796 hashtab_destroy(&p->symtab[i].table); in policydb_destroy()
800 kvfree(p->sym_val_to_name[i]); in policydb_destroy()
802 kfree(p->class_val_to_struct); in policydb_destroy()
803 kfree(p->role_val_to_struct); in policydb_destroy()
804 kfree(p->user_val_to_struct); in policydb_destroy()
805 kvfree(p->type_val_to_struct); in policydb_destroy()
807 avtab_destroy(&p->te_avtab); in policydb_destroy()
811 c = p->ocontexts[i]; in policydb_destroy()
817 p->ocontexts[i] = NULL; in policydb_destroy()
820 g = p->genfs; in policydb_destroy()
834 p->genfs = NULL; in policydb_destroy()
836 cond_policydb_destroy(p); in policydb_destroy()
838 hashtab_map(&p->role_tr, role_tr_destroy, NULL); in policydb_destroy()
839 hashtab_destroy(&p->role_tr); in policydb_destroy()
841 for (ra = p->role_allow; ra; ra = ra->next) { in policydb_destroy()
848 hashtab_map(&p->filename_trans, filenametr_destroy, NULL); in policydb_destroy()
849 hashtab_destroy(&p->filename_trans); in policydb_destroy()
851 hashtab_map(&p->range_tr, range_tr_destroy, NULL); in policydb_destroy()
852 hashtab_destroy(&p->range_tr); in policydb_destroy()
854 if (p->type_attr_map_array) { in policydb_destroy()
855 for (i = 0; i < p->p_types.nprim; i++) in policydb_destroy()
856 ebitmap_destroy(&p->type_attr_map_array[i]); in policydb_destroy()
857 kvfree(p->type_attr_map_array); in policydb_destroy()
860 ebitmap_destroy(&p->filename_trans_ttypes); in policydb_destroy()
861 ebitmap_destroy(&p->policycaps); in policydb_destroy()
862 ebitmap_destroy(&p->permissive_map); in policydb_destroy()
869 int policydb_load_isids(struct policydb *p, struct sidtab *s) in policydb_load_isids() argument
880 head = p->ocontexts[OCON_ISID]; in policydb_load_isids()
906 int policydb_class_isvalid(struct policydb *p, unsigned int class) in policydb_class_isvalid() argument
908 if (!class || class > p->p_classes.nprim) in policydb_class_isvalid()
913 int policydb_role_isvalid(struct policydb *p, unsigned int role) in policydb_role_isvalid() argument
915 if (!role || role > p->p_roles.nprim) in policydb_role_isvalid()
920 int policydb_type_isvalid(struct policydb *p, unsigned int type) in policydb_type_isvalid() argument
922 if (!type || type > p->p_types.nprim) in policydb_type_isvalid()
931 int policydb_context_isvalid(struct policydb *p, struct context *c) in policydb_context_isvalid() argument
936 if (!c->role || c->role > p->p_roles.nprim) in policydb_context_isvalid()
939 if (!c->user || c->user > p->p_users.nprim) in policydb_context_isvalid()
942 if (!c->type || c->type > p->p_types.nprim) in policydb_context_isvalid()
949 role = p->role_val_to_struct[c->role - 1]; in policydb_context_isvalid()
957 usrdatum = p->user_val_to_struct[c->user - 1]; in policydb_context_isvalid()
966 if (!mls_context_isvalid(p, c)) in policydb_context_isvalid()
1036 struct policydb *p, in context_read_and_validate() argument
1050 if (p->policyvers >= POLICYDB_VERSION_MLS) { in context_read_and_validate()
1059 if (!policydb_context_isvalid(p, c)) { in context_read_and_validate()
1098 static int perm_read(struct policydb *p, struct symtab *s, void *fp) in perm_read() argument
1131 static int common_read(struct policydb *p, struct symtab *s, void *fp) in common_read() argument
1161 rc = perm_read(p, &comdatum->permissions, fp); in common_read()
1200 static int read_cons_helper(struct policydb *p, in read_cons_helper() argument
1270 if (p->policyvers >= in read_cons_helper()
1295 static int class_read(struct policydb *p, struct symtab *s, void *fp) in class_read() argument
1333 cladatum->comdatum = symtab_search(&p->p_commons, in class_read()
1342 rc = perm_read(p, &cladatum->permissions, fp); in class_read()
1347 rc = read_cons_helper(p, &cladatum->constraints, ncons, 0, fp); in class_read()
1351 if (p->policyvers >= POLICYDB_VERSION_VALIDATETRANS) { in class_read()
1357 rc = read_cons_helper(p, &cladatum->validatetrans, in class_read()
1363 if (p->policyvers >= POLICYDB_VERSION_NEW_OBJECT_DEFAULTS) { in class_read()
1373 if (p->policyvers >= POLICYDB_VERSION_DEFAULT_TYPE) { in class_read()
1390 static int role_read(struct policydb *p, struct symtab *s, void *fp) in role_read() argument
1402 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_read()
1411 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_read()
1446 static int type_read(struct policydb *p, struct symtab *s, void *fp) in type_read() argument
1458 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in type_read()
1467 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) { in type_read()
1520 static int user_read(struct policydb *p, struct symtab *s, void *fp) in user_read() argument
1532 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_read()
1541 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_read()
1552 if (p->policyvers >= POLICYDB_VERSION_MLS) { in user_read()
1570 static int sens_read(struct policydb *p, struct symtab *s, void *fp) in sens_read() argument
1611 static int cat_read(struct policydb *p, struct symtab *s, void *fp) in cat_read() argument
1644 static int (*read_f[SYM_NUM]) (struct policydb *p, struct symtab *s, void *fp) =
1659 struct policydb *p = datap; in user_bounds_sanity_check() local
1674 upper = p->user_val_to_struct[upper->bounds - 1]; in user_bounds_sanity_check()
1681 sym_name(p, SYM_USERS, user->value - 1), in user_bounds_sanity_check()
1682 sym_name(p, SYM_ROLES, bit), in user_bounds_sanity_check()
1683 sym_name(p, SYM_USERS, upper->value - 1)); in user_bounds_sanity_check()
1695 struct policydb *p = datap; in role_bounds_sanity_check() local
1710 upper = p->role_val_to_struct[upper->bounds - 1]; in role_bounds_sanity_check()
1717 sym_name(p, SYM_ROLES, role->value - 1), in role_bounds_sanity_check()
1718 sym_name(p, SYM_TYPES, bit), in role_bounds_sanity_check()
1719 sym_name(p, SYM_ROLES, upper->value - 1)); in role_bounds_sanity_check()
1731 struct policydb *p = datap; in type_bounds_sanity_check() local
1743 upper = p->type_val_to_struct[upper->bounds - 1]; in type_bounds_sanity_check()
1750 sym_name(p, SYM_TYPES, upper->value - 1)); in type_bounds_sanity_check()
1758 static int policydb_bounds_sanity_check(struct policydb *p) in policydb_bounds_sanity_check() argument
1762 if (p->policyvers < POLICYDB_VERSION_BOUNDARY) in policydb_bounds_sanity_check()
1765 rc = hashtab_map(&p->p_users.table, user_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1769 rc = hashtab_map(&p->p_roles.table, role_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1773 rc = hashtab_map(&p->p_types.table, type_bounds_sanity_check, p); in policydb_bounds_sanity_check()
1780 u16 string_to_security_class(struct policydb *p, const char *name) in string_to_security_class() argument
1784 cladatum = symtab_search(&p->p_classes, name); in string_to_security_class()
1791 u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) in string_to_av_perm() argument
1797 if (!tclass || tclass > p->p_classes.nprim) in string_to_av_perm()
1800 cladatum = p->class_val_to_struct[tclass-1]; in string_to_av_perm()
1812 static int range_read(struct policydb *p, void *fp) in range_read() argument
1820 if (p->policyvers < POLICYDB_VERSION_MLS) in range_read()
1829 rc = hashtab_init(&p->range_tr, nel); in range_read()
1845 if (p->policyvers >= POLICYDB_VERSION_RANGETRANS) { in range_read()
1851 rt->target_class = p->process_class; in range_read()
1854 if (!policydb_type_isvalid(p, rt->source_type) || in range_read()
1855 !policydb_type_isvalid(p, rt->target_type) || in range_read()
1856 !policydb_class_isvalid(p, rt->target_class)) in range_read()
1869 if (!mls_range_isvalid(p, r)) { in range_read()
1874 rc = hashtab_insert(&p->range_tr, rt, r, rangetr_key_params); in range_read()
1881 hash_eval(&p->range_tr, "rangetr"); in range_read()
1889 static int filename_trans_read_helper_compat(struct policydb *p, void *fp) in filename_trans_read_helper_compat() argument
1921 datum = policydb_filenametr_search(p, &key); in filename_trans_read_helper_compat()
1951 rc = hashtab_insert(&p->filename_trans, ft, datum, in filename_trans_read_helper_compat()
1957 rc = ebitmap_set_bit(&p->filename_trans_ttypes, in filename_trans_read_helper_compat()
1973 static int filename_trans_read_helper(struct policydb *p, void *fp) in filename_trans_read_helper() argument
2040 rc = hashtab_insert(&p->filename_trans, ft, first, in filename_trans_read_helper()
2047 return ebitmap_set_bit(&p->filename_trans_ttypes, ttype, 1); in filename_trans_read_helper()
2062 static int filename_trans_read(struct policydb *p, void *fp) in filename_trans_read() argument
2068 if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS) in filename_trans_read()
2076 if (p->policyvers < POLICYDB_VERSION_COMP_FTRANS) { in filename_trans_read()
2077 p->compat_filename_trans_count = nel; in filename_trans_read()
2079 rc = hashtab_init(&p->filename_trans, (1 << 11)); in filename_trans_read()
2084 rc = filename_trans_read_helper_compat(p, fp); in filename_trans_read()
2089 rc = hashtab_init(&p->filename_trans, nel); in filename_trans_read()
2094 rc = filename_trans_read_helper(p, fp); in filename_trans_read()
2099 hash_eval(&p->filename_trans, "filenametr"); in filename_trans_read()
2103 static int genfs_read(struct policydb *p, void *fp) in genfs_read() argument
2133 for (genfs_p = NULL, genfs = p->genfs; genfs; in genfs_read()
2148 p->genfs = newgenfs; in genfs_read()
2177 rc = context_read_and_validate(&newc->context[0], p, fp); in genfs_read()
2216 static int ocontext_read(struct policydb *p, struct policydb_compat_info *info, in ocontext_read() argument
2241 p->ocontexts[i] = c; in ocontext_read()
2251 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2266 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2269 rc = context_read_and_validate(&c->context[1], p, fp); in ocontext_read()
2280 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2290 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2312 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2326 rc = context_read_and_validate(&c->context[0], p, fp); in ocontext_read()
2357 p, in ocontext_read()
2384 p, in ocontext_read()
2402 int policydb_read(struct policydb *p, void *fp) in policydb_read() argument
2414 policydb_init(p); in policydb_read()
2471 p->policyvers = le32_to_cpu(buf[0]); in policydb_read()
2472 if (p->policyvers < POLICYDB_VERSION_MIN || in policydb_read()
2473 p->policyvers > POLICYDB_VERSION_MAX) { in policydb_read()
2481 p->mls_enabled = 1; in policydb_read()
2484 if (p->policyvers < POLICYDB_VERSION_MLS) { in policydb_read()
2487 p->policyvers); in policydb_read()
2491 p->reject_unknown = !!(le32_to_cpu(buf[1]) & REJECT_UNKNOWN); in policydb_read()
2492 p->allow_unknown = !!(le32_to_cpu(buf[1]) & ALLOW_UNKNOWN); in policydb_read()
2495 p->android_netlink_route = 1; in policydb_read()
2499 p->android_netlink_getneigh = 1; in policydb_read()
2502 if (p->policyvers >= POLICYDB_VERSION_POLCAP) { in policydb_read()
2503 rc = ebitmap_read(&p->policycaps, fp); in policydb_read()
2508 if (p->policyvers >= POLICYDB_VERSION_PERMISSIVE) { in policydb_read()
2509 rc = ebitmap_read(&p->permissive_map, fp); in policydb_read()
2515 info = policydb_lookup_compat(p->policyvers); in policydb_read()
2518 "for version %d\n", p->policyvers); in policydb_read()
2539 rc = symtab_init(&p->symtab[i], nel); in policydb_read()
2544 rc = roles_init(p); in policydb_read()
2550 rc = read_f[i](p, &p->symtab[i], fp); in policydb_read()
2555 p->symtab[i].nprim = nprim; in policydb_read()
2559 p->process_class = string_to_security_class(p, "process"); in policydb_read()
2560 if (!p->process_class) { in policydb_read()
2565 rc = avtab_read(&p->te_avtab, fp, p); in policydb_read()
2569 if (p->policyvers >= POLICYDB_VERSION_BOOL) { in policydb_read()
2570 rc = cond_read_list(p, fp); in policydb_read()
2580 rc = hashtab_init(&p->role_tr, nel); in policydb_read()
2601 if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { in policydb_read()
2607 rtk->tclass = p->process_class; in policydb_read()
2610 if (!policydb_role_isvalid(p, rtk->role) || in policydb_read()
2611 !policydb_type_isvalid(p, rtk->type) || in policydb_read()
2612 !policydb_class_isvalid(p, rtk->tclass) || in policydb_read()
2613 !policydb_role_isvalid(p, rtd->new_role)) in policydb_read()
2616 rc = hashtab_insert(&p->role_tr, rtk, rtd, roletr_key_params); in policydb_read()
2637 p->role_allow = ra; in policydb_read()
2645 if (!policydb_role_isvalid(p, ra->role) || in policydb_read()
2646 !policydb_role_isvalid(p, ra->new_role)) in policydb_read()
2651 rc = filename_trans_read(p, fp); in policydb_read()
2655 rc = policydb_index(p); in policydb_read()
2660 perm = string_to_av_perm(p, p->process_class, "transition"); in policydb_read()
2665 p->process_trans_perms = perm; in policydb_read()
2666 perm = string_to_av_perm(p, p->process_class, "dyntransition"); in policydb_read()
2671 p->process_trans_perms |= perm; in policydb_read()
2673 rc = ocontext_read(p, info, fp); in policydb_read()
2677 rc = genfs_read(p, fp); in policydb_read()
2681 rc = range_read(p, fp); in policydb_read()
2686 p->type_attr_map_array = kvcalloc(p->p_types.nprim, in policydb_read()
2687 sizeof(*p->type_attr_map_array), in policydb_read()
2689 if (!p->type_attr_map_array) in policydb_read()
2693 for (i = 0; i < p->p_types.nprim; i++) in policydb_read()
2694 ebitmap_init(&p->type_attr_map_array[i]); in policydb_read()
2696 for (i = 0; i < p->p_types.nprim; i++) { in policydb_read()
2697 struct ebitmap *e = &p->type_attr_map_array[i]; in policydb_read()
2699 if (p->policyvers >= POLICYDB_VERSION_AVTAB) { in policydb_read()
2710 rc = policydb_bounds_sanity_check(p); in policydb_read()
2720 policydb_destroy(p); in policydb_read()
2843 struct policydb *p = pd->p; in role_trans_write_one() local
2853 if (p->policyvers >= POLICYDB_VERSION_ROLETRANS) { in role_trans_write_one()
2862 static int role_trans_write(struct policydb *p, void *fp) in role_trans_write() argument
2864 struct policy_data pd = { .p = p, .fp = fp }; in role_trans_write()
2868 buf[0] = cpu_to_le32(p->role_tr.nel); in role_trans_write()
2873 return hashtab_map(&p->role_tr, role_trans_write_one, &pd); in role_trans_write()
2904 static int context_write(struct policydb *p, struct context *c, in context_write() argument
3001 static int write_cons_helper(struct policydb *p, struct constraint_node *node, in write_cons_helper() argument
3032 if (p->policyvers >= in write_cons_helper()
3054 struct policydb *p = pd->p; in class_write() local
3095 rc = write_cons_helper(p, cladatum->constraints, fp); in class_write()
3109 rc = write_cons_helper(p, cladatum->validatetrans, fp); in class_write()
3113 if (p->policyvers >= POLICYDB_VERSION_NEW_OBJECT_DEFAULTS) { in class_write()
3123 if (p->policyvers >= POLICYDB_VERSION_DEFAULT_TYPE) { in class_write()
3139 struct policydb *p = pd->p; in role_write() local
3148 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in role_write()
3177 struct policydb *p = pd->p; in type_write() local
3187 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) { in type_write()
3218 struct policydb *p = pd->p; in user_write() local
3228 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) in user_write()
3267 static int ocontext_write(struct policydb *p, struct policydb_compat_info *info, in ocontext_write() argument
3278 for (c = p->ocontexts[i]; c; c = c->next) in ocontext_write()
3284 for (c = p->ocontexts[i]; c; c = c->next) { in ocontext_write()
3291 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3305 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3308 rc = context_write(p, &c->context[1], fp); in ocontext_write()
3319 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3329 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3343 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3355 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3373 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3387 rc = context_write(p, &c->context[0], fp); in ocontext_write()
3397 static int genfs_write(struct policydb *p, void *fp) in genfs_write() argument
3406 for (genfs = p->genfs; genfs; genfs = genfs->next) in genfs_write()
3412 for (genfs = p->genfs; genfs; genfs = genfs->next) { in genfs_write()
3441 rc = context_write(p, &c->context[0], fp); in genfs_write()
3456 struct policydb *p = pd->p; in range_write_helper() local
3464 if (p->policyvers >= POLICYDB_VERSION_RANGETRANS) { in range_write_helper()
3477 static int range_write(struct policydb *p, void *fp) in range_write() argument
3483 pd.p = p; in range_write()
3486 buf[0] = cpu_to_le32(p->range_tr.nel); in range_write()
3492 rc = hashtab_map(&p->range_tr, range_write_helper, &pd); in range_write()
3585 static int filename_trans_write(struct policydb *p, void *fp) in filename_trans_write() argument
3590 if (p->policyvers < POLICYDB_VERSION_FILENAME_TRANS) in filename_trans_write()
3593 if (p->policyvers < POLICYDB_VERSION_COMP_FTRANS) { in filename_trans_write()
3594 buf[0] = cpu_to_le32(p->compat_filename_trans_count); in filename_trans_write()
3599 rc = hashtab_map(&p->filename_trans, in filename_trans_write()
3602 buf[0] = cpu_to_le32(p->filename_trans.nel); in filename_trans_write()
3607 rc = hashtab_map(&p->filename_trans, filename_write_helper, fp); in filename_trans_write()
3617 int policydb_write(struct policydb *p, void *fp) in policydb_write() argument
3632 if (p->policyvers < POLICYDB_VERSION_AVTAB) { in policydb_write()
3634 " Because it is less than version %d\n", p->policyvers, in policydb_write()
3640 if (p->mls_enabled) in policydb_write()
3643 if (p->reject_unknown) in policydb_write()
3645 if (p->allow_unknown) in policydb_write()
3660 info = policydb_lookup_compat(p->policyvers); in policydb_write()
3663 "version %d", p->policyvers); in policydb_write()
3667 buf[0] = cpu_to_le32(p->policyvers); in policydb_write()
3676 if (p->policyvers >= POLICYDB_VERSION_POLCAP) { in policydb_write()
3677 rc = ebitmap_write(&p->policycaps, fp); in policydb_write()
3682 if (p->policyvers >= POLICYDB_VERSION_PERMISSIVE) { in policydb_write()
3683 rc = ebitmap_write(&p->permissive_map, fp); in policydb_write()
3693 pd.p = p; in policydb_write()
3695 buf[0] = cpu_to_le32(p->symtab[i].nprim); in policydb_write()
3696 buf[1] = cpu_to_le32(p->symtab[i].table.nel); in policydb_write()
3701 rc = hashtab_map(&p->symtab[i].table, write_f[i], &pd); in policydb_write()
3706 rc = avtab_write(p, &p->te_avtab, fp); in policydb_write()
3710 rc = cond_write_list(p, fp); in policydb_write()
3714 rc = role_trans_write(p, fp); in policydb_write()
3718 rc = role_allow_write(p->role_allow, fp); in policydb_write()
3722 rc = filename_trans_write(p, fp); in policydb_write()
3726 rc = ocontext_write(p, info, fp); in policydb_write()
3730 rc = genfs_write(p, fp); in policydb_write()
3734 rc = range_write(p, fp); in policydb_write()
3738 for (i = 0; i < p->p_types.nprim; i++) { in policydb_write()
3739 struct ebitmap *e = &p->type_attr_map_array[i]; in policydb_write()