libsepol: Do not reject all type rules in conditionals when validating
PATCH 1/1 libsepol: Do not reject all type rules in conditionals when validating
Commit 1c91bc84 ("libsepol: reject self flag in type rules in old policies") actually rejects all type rules in conditionals in modular policies prior to version 21 (MOD_POLICYDB_VERSION_SELF_TYPETRANS).
The problem is because of fall-through in a switch statement when the avrule flags are 0. Instead, break rather than fall-through when avrule flags are 0.
--- libsepol/src/policydb_validate.c | 1 + 1 file changed, 1 insertion(+)
libsepol/src/policydb_validate.c +1 -0
@@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, intswitch (avrule->flags) {case 0 : +break ;case RULE_SELF : if (p->policyvers != POLICY_KERN && p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS &&
Signature · 1 line
2.45.2
Quoted 8 lines · James Carter
Commit
1c91bc84("libsepol: reject self flag in type rules in old policies") actually rejects all type rules in conditionals in modular policies prior to version 21 (MOD_POLICYDB_VERSION_SELF_TYPETRANS).The problem is because of fall-through in a switch statement when the avrule flags are 0. Instead, break rather than fall-through when avrule flags are 0.
Thanks for spotting this.
I'am probably going to look to enhance the downgrade unit test for the next validate updates...
Quoted 19 lines
--- libsepol/src/policydb_validate.c | 1 + 1 file changed, 1 insertion(+)libsepol/src/policydb_validate.c +1
-1@@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, intswitch (avrule->flags) {case 0 : +break ;case RULE_SELF : if (p->policyvers != POLICY_KERN && p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS && --2.45.2
Petr Lautrbach
Acked-byQuoted 10 lines · Christian Göttsche
Quoted 8 lines · James Carter
Commit
1c91bc84("libsepol: reject self flag in type rules in old policies") actually rejects all type rules in conditionals in modular policies prior to version 21 (MOD_POLICYDB_VERSION_SELF_TYPETRANS).The problem is because of fall-through in a switch statement when the avrule flags are 0. Instead, break rather than fall-through when avrule flags are 0.
Quoted 5 lines
Thanks for spotting this.
I'am probably going to look to enhance the downgrade unit test for the next validate updates...Reviewed-by Christian Göttsche <[email protected]>
Quoted 20 lines
Quoted 20 lines
--- libsepol/src/policydb_validate.c | 1 + 1 file changed, 1 insertion(+)libsepol/src/policydb_validate.c +1
-1@@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, intswitch (avrule->flags) {case 0 : +break ;case RULE_SELF : if (p->policyvers != POLICY_KERN && p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS && --2.45.2
Quoted 13 lines · Petr Lautrbach
Quoted 10 lines · Christian Göttsche
Quoted 8 lines · James Carter
Commit
1c91bc84("libsepol: reject self flag in type rules in old policies") actually rejects all type rules in conditionals in modular policies prior to version 21 (MOD_POLICYDB_VERSION_SELF_TYPETRANS).The problem is because of fall-through in a switch statement when the avrule flags are 0. Instead, break rather than fall-through when avrule flags are 0.
Quoted 8 lines
Quoted 5 lines
Thanks for spotting this.
I'am probably going to look to enhance the downgrade unit test for the next validate updates...Reviewed-by Christian Göttsche <[email protected]>Acked-by Petr Lautrbach <[email protected]>
This has been merged.
Thanks,
Jim
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
--- libsepol/src/policydb_validate.c | 1 + 1 file changed, 1 insertion(+)libsepol/src/policydb_validate.c +1
-1@@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, intswitch (avrule->flags) {case 0 : +break ;case RULE_SELF : if (p->policyvers != POLICY_KERN && p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS && --2.45.2