-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5yV5QACgkQrlYvE4MpobPY2wCfT4j7PrB4gsk8woE1TwrZkzDU fe8AoLv7HtcNetck9PYnkixZvR/8tRXo =J/K/ -----END PGP SIGNATURE-----
>From e6be20220ca6e31d7064c4eef4836c807daa0f9b Mon Sep 17 00:00:00 2001 From: Harry Ciao <qingtao.cao@xxxxxxxxxxxxx> Date: Thu, 1 Sep 2011 11:29:43 +0800 Subject: [PATCH 47/67] libsepol: Copy and check the cond_bool_datum_t.flags during link. Copy the TUNABLE flag for cond_bool_datum_t during link, and check if there is a mismatch between boolean/tunable declaration and usage among modules. If this is the case, bail out with errors. Signed-off-by: Harry Ciao <qingtao.cao@xxxxxxxxxxxxx> Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- libsepol/src/link.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libsepol/src/link.c b/libsepol/src/link.c index 421c47b..ee9675b 100644 --- a/libsepol/src/link.c +++ b/libsepol/src/link.c @@ -587,7 +587,18 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, } state->base->p_bools.nprim++; base_bool = new_bool; - + base_bool->flags = booldatum->flags; + } else if ((booldatum->flags & COND_BOOL_FLAGS_TUNABLE) != + (base_bool->flags & COND_BOOL_FLAGS_TUNABLE)) { + /* A mismatch between boolean/tunable declaration + * and usage(for example a boolean used in the + * tunable_policy() or vice versa). + * + * This is not allowed and bail out with errors */ + ERR(state->handle, + "%s: Mismatch between boolean/tunable definition " + "and usage for %s", state->cur_mod_name, id); + return -1; } /* Get the scope info for this boolean to see if this is the declaration, @@ -595,9 +606,12 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, scope = hashtab_search(state->cur->policy->p_bools_scope.table, id); if (!scope) return SEPOL_ERR; - if (scope->scope == SCOPE_DECL) + if (scope->scope == SCOPE_DECL) { base_bool->state = booldatum->state; - + /* Only the declaration rather than requirement + * decides if it is a boolean or tunable. */ + base_bool->flags = booldatum->flags; + } state->cur->map[SYM_BOOLS][booldatum->s.value - 1] = base_bool->s.value; return 0; -- 1.7.6.2