Changeset 28

Show
Ignore:
Timestamp:
10/02/06 08:32:17 (2 years ago)
Author:
ccase
Message:

updated to selinux 2006-10-02

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • upstream/selinux/checkpolicy/ChangeLog

    r10 r28  
     11.30.12 2006-09-28 
     2        * Merged user and range_transition support for modules from  
     3          Darrel Goeddel 
     4 
    151.30.11 2006-09-05 
    26        * merged range_transition enhancements and user module format 
  • upstream/selinux/checkpolicy/VERSION

    r10 r28  
    1 1.30.11 
     11.30.12 
  • upstream/selinux/checkpolicy/module_compiler.c

    r10 r28  
    938938} 
    939939 
     940int require_sens(int pass) 
     941{ 
     942        char *id = queue_remove(id_queue); 
     943        level_datum_t *level = NULL; 
     944        int retval; 
     945        if (pass == 2) { 
     946                free(id); 
     947                return 0; 
     948        } 
     949        if (!id) { 
     950                yyerror("no sensitivity name"); 
     951                return -1; 
     952        } 
     953        level = malloc(sizeof(level_datum_t)); 
     954        if (!level) { 
     955                free(id); 
     956                yyerror("Out of memory!"); 
     957                return -1; 
     958        } 
     959        level_datum_init(level); 
     960        level->level = malloc(sizeof(mls_level_t)); 
     961        if (!level->level) { 
     962                free(id); 
     963                level_datum_destroy(level); 
     964                free(level); 
     965                yyerror("Out of memory!"); 
     966                return -1; 
     967        } 
     968        mls_level_init(level->level); 
     969        retval = require_symbol(SYM_LEVELS, id, (hashtab_datum_t *) level, 
     970                                &level->level->sens, &level->level->sens); 
     971        if (retval != 0) { 
     972                free(id); 
     973                mls_level_destroy(level->level); 
     974                free(level->level); 
     975                level_datum_destroy(level); 
     976                free(level); 
     977        } 
     978        switch (retval) { 
     979        case -3:{ 
     980                        yyerror("Out of memory!"); 
     981                        return -1; 
     982                } 
     983        case -2:{ 
     984                        yyerror("duplicate declaration of sensitivity"); 
     985                        return -1; 
     986                } 
     987        case -1:{ 
     988                        yyerror("could not require sensitivity here"); 
     989                        return -1; 
     990                } 
     991        case 0:{ 
     992                        return 0; 
     993                } 
     994        case 1:{ 
     995                        return 0;       /* sensitivity already required */ 
     996                } 
     997        default:{ 
     998                        assert(0);      /* should never get here */ 
     999                } 
     1000        } 
     1001} 
     1002 
     1003int require_cat(int pass) 
     1004{ 
     1005        char *id = queue_remove(id_queue); 
     1006        cat_datum_t *cat = NULL; 
     1007        int retval; 
     1008        if (pass == 2) { 
     1009                free(id); 
     1010                return 0; 
     1011        } 
     1012        if (!id) { 
     1013                yyerror("no category name"); 
     1014                return -1; 
     1015        } 
     1016        cat = malloc(sizeof(cat_datum_t)); 
     1017        if (!cat) { 
     1018                free(id); 
     1019                yyerror("Out of memory!"); 
     1020                return -1; 
     1021        } 
     1022        cat_datum_init(cat); 
     1023 
     1024        retval = require_symbol(SYM_CATS, id, (hashtab_datum_t *) cat, 
     1025                                &cat->s.value, &cat->s.value); 
     1026        if (retval != 0) { 
     1027                free(id); 
     1028                cat_datum_destroy(cat); 
     1029                free(cat); 
     1030        } 
     1031        switch (retval) { 
     1032        case -3:{ 
     1033                        yyerror("Out of memory!"); 
     1034                        return -1; 
     1035                } 
     1036        case -2:{ 
     1037                        yyerror("duplicate declaration of category"); 
     1038                        return -1; 
     1039                } 
     1040        case -1:{ 
     1041                        yyerror("could not require category here"); 
     1042                        return -1; 
     1043                } 
     1044        case 0:{ 
     1045                        return 0; 
     1046                } 
     1047        case 1:{ 
     1048                        return 0;       /* category already required */ 
     1049                } 
     1050        default:{ 
     1051                        assert(0);      /* should never get here */ 
     1052                } 
     1053        } 
     1054} 
     1055 
    9401056static int is_scope_in_stack(scope_datum_t * scope, scope_stack_t * stack) 
    9411057{ 
  • upstream/selinux/checkpolicy/module_compiler.h

    r10 r28  
    5757int require_user(int pass); 
    5858int require_bool(int pass); 
     59int require_sens(int pass); 
     60int require_cat(int pass); 
    5961 
    6062/* Check if an identifier is within the scope of the current 
  • upstream/selinux/checkpolicy/policy_parse.y

    r10 r28  
    835835                        | USER        { $$ = require_user; } 
    836836                        | BOOL        { $$ = require_bool; } 
    837 /* MLS-enabled modules are not implemented at this time. 
    838837                        | SENSITIVITY { $$ = require_sens; } 
    839838                        | CATEGORY    { $$ = require_cat; } 
    840 */ 
    841839                        ; 
    842840require_id_list         : identifier 
     
    13021300                goto bad; 
    13031301        } 
    1304         memset(level, 0, sizeof(mls_level_t)); 
     1302        mls_level_init(level); 
    13051303        level->sens = 0;        /* actual value set in define_dominance */ 
    13061304        ebitmap_init(&level->cat);      /* actual value set in define_level */ 
     
    13111309                goto bad; 
    13121310        } 
    1313         memset(datum, 0, sizeof(level_datum_t)); 
     1311        level_datum_init(datum); 
    13141312        datum->isalias = FALSE; 
    13151313        datum->level = level; 
     
    13481346                        goto bad_alias; 
    13491347                } 
    1350                 memset(aliasdatum, 0, sizeof(level_datum_t)); 
     1348                level_datum_init(aliasdatum); 
    13511349                aliasdatum->isalias = TRUE; 
    13521350                aliasdatum->level = level; 
     
    13851383        if (level) 
    13861384                free(level); 
    1387         if (datum) 
     1385        if (datum) { 
     1386                level_datum_destroy(datum); 
    13881387                free(datum); 
     1388        } 
    13891389        return -1; 
    13901390 
     
    13921392        if (id) 
    13931393                free(id); 
    1394         if (aliasdatum) 
     1394        if (aliasdatum) { 
     1395                level_datum_destroy(aliasdatum); 
    13951396                free(aliasdatum); 
     1397        } 
    13961398        return -1; 
    13971399} 
     
    14811483                goto bad; 
    14821484        } 
    1483         memset(datum, 0, sizeof(cat_datum_t)); 
     1485        cat_datum_init(datum); 
    14841486        datum->isalias = FALSE; 
    14851487 
     
    15181520                        goto bad_alias; 
    15191521                } 
    1520                 memset(aliasdatum, 0, sizeof(cat_datum_t)); 
     1522                cat_datum_init(aliasdatum); 
    15211523                aliasdatum->isalias = TRUE; 
    15221524                aliasdatum->s.value = datum->s.value; 
     
    15551557        if (id) 
    15561558                free(id); 
    1557         if (datum) 
     1559        if (datum) { 
     1560                cat_datum_destroy(datum); 
    15581561                free(datum); 
     1562        } 
    15591563        return -1; 
    15601564 
     
    15621566        if (id) 
    15631567                free(id); 
    1564         if (aliasdatum) 
     1568        if (aliasdatum) { 
     1569                cat_datum_destroy(aliasdatum); 
    15651570                free(aliasdatum); 
     1571        } 
    15661572        return -1; 
    15671573} 
     
    36833689        int l; 
    36843690 
    3685         if (policydbp->policy_type == POLICY_MOD && mlspol) { 
    3686                 yyerror("Users cannot be declared in MLS modules"); 
    3687                 return -1; 
    3688         } 
    3689  
    36903691        if (pass == 1) { 
    36913692                while ((id = queue_remove(id_queue))) 
  • upstream/selinux/libselinux/ChangeLog

    r10 r28  
     11.30.29 2006-09-29 
     2        * Merged av_permissions.h update from Steve Grubb, 
     3          adding setsockcreate and polmatch definitions. 
     4 
    151.30.28 2006-09-13 
    26        * Merged patch from Steve Smalley to fix SIGPIPE in setrans_client 
  • upstream/selinux/libselinux/VERSION

    r10 r28  
    1 1.30.28 
     11.30.29 
  • upstream/selinux/libselinux/include/selinux/av_permissions.h

    r10 r28  
    469469#define PROCESS__EXECHEAP                         0x08000000UL 
    470470#define PROCESS__SETKEYCREATE                     0x10000000UL 
     471#define PROCESS__SETSOCKCREATE                    0x20000000UL 
    471472 
    472473#define IPC__CREATE                               0x00000001UL 
     
    911912#define ASSOCIATION__RECVFROM                     0x00000002UL 
    912913#define ASSOCIATION__SETCONTEXT                   0x00000004UL 
     914#define ASSOCIATION__POLMATCH                     0x00000008UL 
    913915 
    914916#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL 
  • upstream/selinux/libselinux/src/setrans_client.c

    r10 r28  
    8989        memset(&msgh, 0, sizeof(msgh)); 
    9090        msgh.msg_iov = iov; 
    91         msgh.msg_iovlen = sizeof(iov)/sizeof(iov[0]); 
     91        msgh.msg_iovlen = sizeof(iov) / sizeof(iov[0]); 
    9292 
    9393        expected = 0; 
    94         for (i = 0; i < sizeof(iov)/sizeof(iov[0]); i++) 
     94        for (i = 0; i < sizeof(iov) / sizeof(iov[0]); i++) 
    9595                expected += iov[i].iov_len; 
    9696 
    97         while (((count = sendmsg(fd, &msgh, MSG_NOSIGNAL)) < 0) && (errno == EINTR)) ; 
     97        while (((count = sendmsg(fd, &msgh, MSG_NOSIGNAL)) < 0) 
     98               && (errno == EINTR)) ; 
    9899        if (count < 0 || count != expected) 
    99100                return -1; 
  • upstream/selinux/libsemanage/ChangeLog

    r10 r28  
     11.6.17 2006-09-29 
     2        * Merged patch to skip reload if no active store exists and 
     3          the store path doesn't match the active store path from Dan Walsh. 
     4        * Merged patch to not destroy sepol handle on error path of 
     5          connect from James Athey. 
     6        * Merged patch to add genhomedircon path to semanage.conf from 
     7          James Athey.  
     8 
    191.6.16 2006-08-14 
    210        * Make most copy errors fatal, but allow exceptions for 
  • upstream/selinux/libsemanage/VERSION

    r10 r28  
    1 1.6.16 
     11.6.17 
  • upstream/selinux/libsemanage/src/conf-parse.y

    r10 r28  
    1 /* Author: Jason Tang     <jtang@tresys.com> 
     1/* Authors: Jason Tang     <jtang@tresys.com> 
     2 *          James Athey    <jathey@tresys.com> 
    23 * 
    3  * Copyright (C) 2004-2005 Tresys Technology, LLC 
     4 * Copyright (C) 2004-2006 Tresys Technology, LLC 
    45 * 
    56 *  This library is free software; you can redistribute it and/or 
     
    5758 
    5859%token MODULE_STORE VERSION EXPAND_CHECK FILE_MODE 
    59 %token LOAD_POLICY_START SETFILES_START 
     60%token LOAD_POLICY_START SETFILES_START GENHOMEDIRCON_START 
    6061%token VERIFY_MOD_START VERIFY_LINKED_START VERIFY_KERNEL_START BLOCK_END 
    6162%token PROG_PATH PROG_ARGS 
     
    134135                        current_conf->setfiles = NULL; 
    135136                        if (new_external_prog(&current_conf->setfiles) == -1) { 
     137                                parse_errors++; 
     138                                YYABORT; 
     139                        } 
     140                } 
     141        |       GENHOMEDIRCON_START { 
     142                        semanage_conf_external_prog_destroy(current_conf->genhomedircon); 
     143                        current_conf->genhomedircon = NULL; 
     144                        if (new_external_prog(&current_conf->genhomedircon) == -1) { 
    136145                                parse_errors++; 
    137146                                YYABORT; 
  • upstream/selinux/libsemanage/src/conf-scan.l

    r10 r28  
    1 /* Author: Jason Tang     <jtang@tresys.com> 
     1/* Authors: Jason Tang     <jtang@tresys.com> 
     2 *          James Athey    <jathey@tresys.com> 
    23 * 
    3  * Copyright (C) 2004-2005 Tresys Technology, LLC 
     4 * Copyright (C) 2004-2006 Tresys Technology, LLC 
    45 * 
    56 *  This library is free software; you can redistribute it and/or 
     
    4445"[load_policy]"   return LOAD_POLICY_START; 
    4546"[setfiles]"      return SETFILES_START; 
     47"[genhomedircon]" return GENHOMEDIRCON_START; 
    4648"[verify module]" return VERIFY_MOD_START; 
    4749"[verify linked]" return VERIFY_LINKED_START; 
  • upstream/selinux/libsemanage/src/direct_api.c

    r10 r28  
    219219      err: 
    220220        ERR(sh, "could not establish direct connection"); 
    221         sepol_handle_destroy(sh->sepolh); 
    222221        return STATUS_ERR; 
    223222} 
  • upstream/selinux/libsemanage/src/semanage_store.c

    r10 r28  
    11111111                        goto skip_reload; 
    11121112                } 
    1113         } 
     1113        } else if (errno == ENOENT && 
     1114                   strcmp(really_active_store, storepath) != 0) 
     1115                goto skip_reload; 
    11141116 
    11151117        if (semanage_reload_policy(sh)) { 
  • upstream/selinux/libsepol/ChangeLog

    r10 r28  
     11.12.28 2006-09-28 
     2        * Build libsepol's static object files with -fpic 
     3 
     41.12.27 2006-09-28 
     5        * Merged mls user and range_transition support in modules 
     6          from Darrel Goeddel 
     7 
    181.12.26 2006-09-05 
    29        * Merged range transition enhancements and user format changes 
  • upstream/selinux/libsepol/VERSION

    r10 r28  
    1 1.12.26 
     11.12.28 
  • upstream/selinux/libsepol/include/sepol/policydb/policydb.h

    r10 r28  
    533533extern void user_datum_init(user_datum_t * x); 
    534534extern void user_datum_destroy(user_datum_t * x); 
     535extern void level_datum_init(level_datum_t * x); 
     536extern void level_datum_destroy(level_datum_t * x); 
     537extern void cat_datum_init(cat_datum_t * x); 
     538extern void cat_datum_destroy(cat_datum_t * x); 
    535539 
    536540extern int check_assertions(sepol_handle_t * handle, 
  • upstream/selinux/libsepol/src/Makefile

    r10 r28  
    2525 
    2626%.o:  %.c  
    27         $(CC) $(CFLAGS) -c -o $@ $< 
     27        $(CC) $(CFLAGS) -fpic -c -o $@ $< 
    2828 
    2929%.lo:  %.c 
  • upstream/selinux/libsepol/src/expand.c

    r10 r28  
    824824                INFO(state->handle, "copying sensitivity level %s", id); 
    825825 
    826         if ((new_level = 
    827              (level_datum_t *) calloc(1, sizeof(*new_level))) == NULL 
    828             || (new_level->level = 
    829                 (mls_level_t *) calloc(1, sizeof(mls_level_t))) == NULL 
    830             || (new_id = strdup(id)) == NULL) { 
     826        new_level = (level_datum_t *) malloc(sizeof(level_datum_t)); 
     827        if (!new_level) 
    831828                goto out_of_mem; 
    832         } 
     829        level_datum_init(new_level); 
     830        new_level->level = (mls_level_t *) malloc(sizeof(mls_level_t)); 
     831        if (!new_level->level) 
     832                goto out_of_mem; 
     833        mls_level_init(new_level->level); 
     834        new_id = strdup(id); 
     835        if (!new_id) 
     836                goto out_of_mem; 
    833837 
    834838        if (mls_level_cpy(new_level->level, level->level)) { 
     
    848852        ERR(state->handle, "Out of memory!"); 
    849853        if (new_level != NULL && new_level->level != NULL) { 
    850                 ebitmap_destroy(&new_level->level->cat); 
     854                mls_level_destroy(new_level->level); 
    851855                free(new_level->level); 
    852856        } 
     857        level_datum_destroy(new_level); 
    853858        free(new_level); 
    854859        free(new_id); 
     
    871876                INFO(state->handle, "copying category attribute %s", id); 
    872877 
    873         if ((new_cat = (cat_datum_t *) calloc(1, sizeof(*new_cat))) == NULL || 
    874             (new_id = strdup(id)) == NULL) { 
     878        new_cat = (cat_datum_t *) malloc(sizeof(cat_datum_t)); 
     879        if (!new_cat) 
    875880                goto out_of_mem; 
    876         } 
     881        cat_datum_init(new_cat); 
     882        new_id = strdup(id); 
     883        if (!new_id) 
     884                goto out_of_mem; 
    877885 
    878886        new_cat->s.value = cat->s.value; 
     
    888896      out_of_mem: 
    889897        ERR(state->handle, "Out of memory!"); 
     898        cat_datum_destroy(new_cat); 
    890899        free(new_cat); 
    891900        free(new_id); 
  • upstream/selinux/libsepol/src/link.c

    r10 r28  
    469469        user_datum_t *user, *base_user, *new_user = NULL; 
    470470        link_state_t *state = (link_state_t *) data; 
    471         scope_datum_t *scope; 
    472471 
    473472        user = (user_datum_t *) datum; 
    474         if (state->base->mls) { 
    475                 scope = 
    476                     hashtab_search(state->cur->policy->p_users_scope.table, id); 
    477                 if (!scope) { 
    478                         ERR(state->handle, 
    479                             "No scope information for user %s in module %s\n", 
    480                             id, state->cur_mod_name); 
    481                         return -1; 
    482                 } 
    483                 if (scope->scope == SCOPE_DECL) { 
    484                         ERR(state->handle, 
    485                             "Users cannot be declared in MLS modules"); 
    486                         return -1; 
    487                 } 
    488                 /* required users fall through */ 
    489         } 
    490473 
    491474        base_user = hashtab_search(state->base->p_users.table, id); 
     
    503486                } 
    504487                user_datum_init(new_user); 
    505                 /* new_users's roles field will be copied during 
    506                    fix_user_callback().  the MLS fields are currently 
    507                    unimplemented */ 
     488                /* new_users's roles and MLS fields will be copied during 
     489                   user_fix_callback(). */ 
    508490 
    509491                new_user->s.value = state->base->p_users.nprim + 1; 
     
    593575} 
    594576 
     577static int sens_copy_callback(hashtab_key_t key, hashtab_datum_t datum, 
     578                              void *data) 
     579{ 
     580        char *id = key; 
     581        level_datum_t *level, *base_level; 
     582        link_state_t *state = (link_state_t *) data; 
     583        scope_datum_t *scope; 
     584 
     585        level = (level_datum_t *) datum; 
     586 
     587        base_level = hashtab_search(state->base->p_levels.table, id); 
     588        if (!base_level) { 
     589                scope = 
     590                    hashtab_search(state->cur->policy->p_sens_scope.table, id); 
     591                if (!scope) 
     592                        return -SEPOL_LINK_ERROR; 
     593                if (scope->scope == SCOPE_DECL) { 
     594                        /* disallow declarations in modules */ 
     595                        ERR(state->handle, 
     596                            "%s: Modules may not declare new sensitivities.", 
     597                            state->cur_mod_name); 
     598                        return -SEPOL_LINK_NOTSUP; 
     599                } 
     600        } 
     601 
     602        state->cur->map[SYM_LEVELS][level->level->sens - 1] = 
     603            base_level->level->sens; 
     604 
     605        return 0; 
     606} 
     607 
     608static int cat_copy_callback(hashtab_key_t key, hashtab_datum_t datum, 
     609                             void *data) 
     610{ 
     611        char *id = key; 
     612        cat_datum_t *cat, *base_cat; 
     613        link_state_t *state = (link_state_t *) data; 
     614        scope_datum_t *scope; 
     615 
     616        cat = (cat_datum_t *) datum; 
     617 
     618        base_cat = hashtab_search(state->base->p_cats.table, id); 
     619        if (!base_cat) { 
     620                scope = 
     621                    hashtab_search(state->cur->policy->p_cat_scope.table, id); 
     622                if (!scope) 
     623                        return -SEPOL_LINK_ERROR; 
     624                if (scope->scope == SCOPE_DECL) { 
     625                        /* disallow declarations in modules */ 
     626                        ERR(state->handle, 
     627                            "%s: Modules may not declare new categories.", 
     628                            state->cur_mod_name); 
     629                        return -SEPOL_LINK_NOTSUP; 
     630                } 
     631        } 
     632 
     633        state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value; 
     634 
     635        return 0; 
     636} 
     637 
    595638static int (*copy_callback_f[SYM_NUM]) (hashtab_key_t key, 
    596639                                        hashtab_datum_t datum, void *datap) = { 
    597640NULL, class_copy_callback, role_copy_callback, type_copy_callback, 
    598             user_copy_callback, bool_copy_callback, NULL, NULL}; 
     641            user_copy_callback, bool_copy_callback, sens_copy_callback, 
     642            cat_copy_callback}; 
    599643 
    600644/* The aliases have to be copied after the types and attributes to be 
     
    784828} 
    785829 
     830static int mls_level_convert(mls_semantic_level_t * src, 
     831                             mls_semantic_level_t * dst, policy_module_t * mod) 
     832{ 
     833        mls_semantic_cat_t *src_cat, *new_cat; 
     834 
     835        assert(mod->map[SYM_LEVELS][src->sens - 1]); 
     836        dst->sens = mod->map[SYM_LEVELS][src->sens - 1]; 
     837 
     838        for (src_cat = src->cat; src_cat; src_cat = src_cat->next) { 
     839                new_cat = 
     840                    (mls_semantic_cat_t *) malloc(sizeof(mls_semantic_cat_t)); 
     841                if (!new_cat) 
     842                        return -1; 
     843                mls_semantic_cat_init(new_cat); 
     844 
     845                new_cat->next = dst->cat; 
     846                dst->cat = new_cat; 
     847 
     848                assert(mod->map[SYM_CATS][src_cat->low - 1]); 
     849                dst->cat->low = mod->map[SYM_CATS][src_cat->low - 1]; 
     850                assert(mod->map[SYM_CATS][src_cat->high - 1]); 
     851                dst->cat->high = mod->map[SYM_CATS][src_cat->high - 1]; 
     852        } 
     853 
     854        return 0; 
     855} 
     856 
     857static int mls_range_convert(mls_semantic_range_t * src, 
     858                             mls_semantic_range_t * dst, policy_module_t * mod) 
     859{ 
     860        if (mls_level_convert(&src->level[0], &dst->level[0], mod)) 
     861                return -1; 
     862        if (mls_level_convert(&src->level[1], &dst->level[1], mod)) 
     863                return -1; 
     864        return 0; 
     865} 
     866 
    786867static int role_fix_callback(hashtab_key_t key, hashtab_datum_t datum, 
    787868                             void *data) 
     
    894975        link_state_t *state = (link_state_t *) data; 
    895976        policy_module_t *mod = state->cur; 
     977        symtab_t *usertab; 
    896978 
    897979        user = (user_datum_t *) datum; 
    898980 
    899981        if (state->dest_decl == NULL) 
    900                 return 0; 
    901  
    902         new_user = hashtab_search(state->dest_decl->p_users.table, id); 
     982                usertab = &state->base->p_users; 
     983        else 
     984                usertab = &state->dest_decl->p_users; 
     985 
     986        new_user = hashtab_search(usertab->table, id); 
    903987        assert(new_user != NULL); 
    904988 
     
    910994                goto cleanup; 
    911995        } 
     996 
     997        if (mls_range_convert(&user->range, &new_user->range, mod)) 
     998                goto cleanup; 
     999 
     1000        if (mls_level_convert(&user->dfltlevel, &new_user->dfltlevel, mod)) 
     1001                goto cleanup; 
    9121002 
    9131003        return 0; 
     
    10971187} 
    10981188 
     1189static int copy_range_trans_list(range_trans_rule_t * rules, 
     1190                                 range_trans_rule_t ** dst, 
     1191                                 policy_module_t * mod, link_state_t * state) 
     1192{ 
     1193        range_trans_rule_t *rule, *new_rule = NULL; 
     1194        unsigned int i; 
     1195        ebitmap_node_t *cnode; 
     1196 
     1197        for (rule = rules; rule; rule = rule->next) { 
     1198                new_rule = 
     1199                    (range_trans_rule_t *) malloc(sizeof(range_trans_rule_t)); 
     1200                if (!new_rule) 
     1201                        goto cleanup; 
     1202 
     1203                range_trans_rule_init(new_rule); 
     1204 
     1205                new_rule->next = *dst; 
     1206                *dst = new_rule; 
     1207 
     1208                if (type_set_convert(&rule->stypes, &new_rule->stypes, 
     1209                                     mod, state)) 
     1210                        goto cleanup; 
     1211 
     1212                if (type_set_convert(&rule->ttypes, &new_rule->ttypes, 
     1213                                     mod, state)) 
     1214                        goto cleanup; 
     1215 
     1216                ebitmap_for_each_bit(&rule->tclasses, cnode, i) { 
     1217                        if (ebitmap_node_get_bit(cnode, i)) { 
     1218                                assert(mod->map[SYM_CLASSES][i]); 
     1219                                if (ebitmap_set_bit 
     1220                                    (&new_rule->tclasses, 
     1221                                     mod->map[SYM_CLASSES][i] - 1, 1)) { 
     1222                                        goto cleanup; 
     1223                                } 
     1224                        } 
     1225                } 
     1226 
     1227                if (mls_range_convert(&rule->trange, &new_rule->trange, mod)) 
     1228                        goto cleanup; 
     1229        } 
     1230        return 0; 
     1231 
     1232      cleanup: 
     1233        ERR(state->handle, "Out of memory!"); 
     1234        range_trans_rule_list_destroy(new_rule); 
     1235        return -1; 
     1236} 
     1237 
    10991238static int copy_cond_list(cond_node_t * list, cond_node_t ** dst, 
    11001239                          policy_module_t * module, link_state_t * state) 
     
    12781417                return -1; 
    12791418        } 
     1419 
     1420        if (copy_range_trans_list(src_decl->range_tr_rules, 
     1421                                  &dest_decl->range_tr_rules, module, state)) 
     1422                return -1; 
    12801423 
    12811424        /* finally copy any identifiers local to this declaration */ 
  • upstream/selinux/libsepol/src/policydb.c

    r10 r28  
    253253} 
    254254 
     255void level_datum_init(level_datum_t * x) 
     256{ 
     257        memset(x, 0, sizeof(level_datum_t)); 
     258} 
     259 
     260void level_datum_destroy(level_datum_t * x __attribute__ ((unused))) 
     261{ 
     262        /* the mls_level_t referenced by the level_datum is managed 
     263         * separately for now, so there is nothing to destroy */ 
     264        return; 
     265} 
     266 
     267void cat_datum_init(cat_datum_t * x) 
     268{ 
     269        memset(x, 0, sizeof(cat_datum_t)); 
     270} 
     271 
     272void cat_datum_destroy(cat_datum_t * x __attribute__ ((unused))) 
     273{ 
     274        /* it's currently a simple struct - really nothing to destroy */ 
     275        return; 
     276} 
     277 
    255278void class_perm_node_init(class_perm_node_t * x) 
    256279{ 
     
    503526        } 
    504527 
    505         if (p->policy_type != POLICY_KERN) { 
     528        /* we do not expand user's MLS info in kernel policies because the 
     529         * semantic representation is not present and we do not expand user's 
     530         * MLS info in module policies because all of the necessary mls 
     531         * information is not present */ 
     532        if (p->policy_type != POLICY_KERN && p->policy_type != POLICY_MOD) { 
    506533                mls_range_destroy(&user->exp_range); 
    507534                if (mls_semantic_range_expand(&user->range, 
     
    908935                free(key); 
    909936        levdatum = (level_datum_t *) datum; 
    910         ebitmap_destroy(&levdatum->level->cat); 
     937        mls_level_destroy(levdatum->level); 
    911938        free(levdatum->level); 
    912         free(datum); 
     939        level_datum_destroy(levdatum); 
     940        free(levdatum); 
    913941        return 0; 
    914942} 
     
    919947        if (key) 
    920948                free(key); 
     949        cat_datum_destroy((cat_datum_t *) datum); 
    921950        free(datum); 
    922951        return 0; 
     
    22002229        uint32_t *buf; 
    22012230 
    2202         memset(lp, 0, sizeof(mls_level_t)); 
     2231        mls_level_init(lp); 
    22032232 
    22042233        buf = next_entry(fp, sizeof(uint32_t)); 
     
    23062335        uint32_t *buf, len; 
    23072336 
    2308         levdatum = calloc(1, sizeof(level_datum_t)); 
     2337        levdatum = malloc(sizeof(level_datum_t)); 
    23092338        if (!levdatum) 
    23102339                return -1; 
     2340        level_datum_init(levdatum); 
    2311