All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libsepol: Do not reject all type rules in conditionals when validating
@ 2024-06-14 19:45 James Carter
  2024-06-15 13:29 ` Christian Göttsche
  0 siblings, 1 reply; 4+ messages in thread
From: James Carter @ 2024-06-14 19:45 UTC (permalink / raw)
  To: selinux; +Cc: cgzones, 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.
---
 libsepol/src/policydb_validate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
index 9746f562..2043e437 100644
--- a/libsepol/src/policydb_validate.c
+++ b/libsepol/src/policydb_validate.c
@@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, int
 
 		switch(avrule->flags) {
 		case 0:
+			break;
 		case RULE_SELF:
 			if (p->policyvers != POLICY_KERN &&
 			    p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS &&
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libsepol: Do not reject all type rules in conditionals when validating
  2024-06-14 19:45 [PATCH] libsepol: Do not reject all type rules in conditionals when validating James Carter
@ 2024-06-15 13:29 ` Christian Göttsche
  2024-06-17  9:09   ` Petr Lautrbach
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Göttsche @ 2024-06-15 13:29 UTC (permalink / raw)
  To: James Carter; +Cc: selinux

On Fri, 14 Jun 2024 at 21:45, James Carter <jwcart2@gmail.com> wrote:
>
> 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...

Reviewed-by: Christian Göttsche <cgzones@googlemail.com>

> ---
>  libsepol/src/policydb_validate.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> index 9746f562..2043e437 100644
> --- a/libsepol/src/policydb_validate.c
> +++ b/libsepol/src/policydb_validate.c
> @@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, int
>
>                 switch(avrule->flags) {
>                 case 0:
> +                       break;
>                 case RULE_SELF:
>                         if (p->policyvers != POLICY_KERN &&
>                             p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS &&
> --
> 2.45.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libsepol: Do not reject all type rules in conditionals when validating
  2024-06-15 13:29 ` Christian Göttsche
@ 2024-06-17  9:09   ` Petr Lautrbach
  2024-06-21 18:07     ` James Carter
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Lautrbach @ 2024-06-17  9:09 UTC (permalink / raw)
  To: selinux; +Cc: Christian Göttsche, James Carter

Christian Göttsche <cgzones@googlemail.com> writes:

> On Fri, 14 Jun 2024 at 21:45, James Carter <jwcart2@gmail.com> wrote:
>>
>> 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...
>
> Reviewed-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: Petr Lautrbach <lautrbach@redhat.com>



>
>> ---
>>  libsepol/src/policydb_validate.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
>> index 9746f562..2043e437 100644
>> --- a/libsepol/src/policydb_validate.c
>> +++ b/libsepol/src/policydb_validate.c
>> @@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, int
>>
>>                 switch(avrule->flags) {
>>                 case 0:
>> +                       break;
>>                 case RULE_SELF:
>>                         if (p->policyvers != POLICY_KERN &&
>>                             p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS &&
>> --
>> 2.45.2
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libsepol: Do not reject all type rules in conditionals when validating
  2024-06-17  9:09   ` Petr Lautrbach
@ 2024-06-21 18:07     ` James Carter
  0 siblings, 0 replies; 4+ messages in thread
From: James Carter @ 2024-06-21 18:07 UTC (permalink / raw)
  To: Petr Lautrbach; +Cc: selinux, Christian Göttsche

On Mon, Jun 17, 2024 at 5:10 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
>
> Christian Göttsche <cgzones@googlemail.com> writes:
>
> > On Fri, 14 Jun 2024 at 21:45, James Carter <jwcart2@gmail.com> wrote:
> >>
> >> 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...
> >
> > Reviewed-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: Petr Lautrbach <lautrbach@redhat.com>
>

This has been merged.
Thanks,
Jim

>
>
> >
> >> ---
> >>  libsepol/src/policydb_validate.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> >> index 9746f562..2043e437 100644
> >> --- a/libsepol/src/policydb_validate.c
> >> +++ b/libsepol/src/policydb_validate.c
> >> @@ -1076,6 +1076,7 @@ static int validate_avrules(sepol_handle_t *handle, const avrule_t *avrule, int
> >>
> >>                 switch(avrule->flags) {
> >>                 case 0:
> >> +                       break;
> >>                 case RULE_SELF:
> >>                         if (p->policyvers != POLICY_KERN &&
> >>                             p->policyvers < MOD_POLICYDB_VERSION_SELF_TYPETRANS &&
> >> --
> >> 2.45.2
> >>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-21 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 19:45 [PATCH] libsepol: Do not reject all type rules in conditionals when validating James Carter
2024-06-15 13:29 ` Christian Göttsche
2024-06-17  9:09   ` Petr Lautrbach
2024-06-21 18:07     ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.