diff mbox series

checkpolicy/fuzz: Update check_level() to use notdefined field

Message ID 20240306143451.2256235-1-jwcart2@gmail.com (mailing list archive)
State Accepted
Commit 8c9d2d656b35
Headers show
Series checkpolicy/fuzz: Update check_level() to use notdefined field | expand

Commit Message

James Carter March 6, 2024, 2:34 p.m. UTC
Commit e16f586 (Fix potential double free of mls_level_t) renamed
the "defined" field to "notdefined", but did not update this use of
it.

Use the new field "notdefined" for the check.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 checkpolicy/fuzz/checkpolicy-fuzzer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Göttsche March 6, 2024, 7:22 p.m. UTC | #1
On Wed, 6 Mar 2024 at 15:34, James Carter <jwcart2@gmail.com> wrote:
>
> Commit e16f586 (Fix potential double free of mls_level_t) renamed
> the "defined" field to "notdefined", but did not update this use of
> it.
>
> Use the new field "notdefined" for the check.

Since the renamed member "notdefined" is checked during validation and
the fuzzer calls policydb_valudate() I think the whole callback can be
removed.

> Signed-off-by: James Carter <jwcart2@gmail.com>
> ---
>  checkpolicy/fuzz/checkpolicy-fuzzer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/checkpolicy/fuzz/checkpolicy-fuzzer.c b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> index 0d749a02..a3da0b57 100644
> --- a/checkpolicy/fuzz/checkpolicy-fuzzer.c
> +++ b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> @@ -135,7 +135,7 @@ static int check_level(hashtab_key_t key, hashtab_datum_t datum, void *arg __att
>         const level_datum_t *levdatum = (level_datum_t *) datum;
>
>         // TODO: drop member defined if proven to be always set
> -       if (!levdatum->isalias && !levdatum->defined) {
> +       if (!levdatum->isalias && levdatum->notdefined) {
>                 fprintf(stderr,
>                         "Error:  sensitivity %s was not used in a level definition!\n",
>                         key);
> --
> 2.44.0
>
James Carter March 7, 2024, 2:15 p.m. UTC | #2
On Wed, Mar 6, 2024 at 2:22 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> On Wed, 6 Mar 2024 at 15:34, James Carter <jwcart2@gmail.com> wrote:
> >
> > Commit e16f586 (Fix potential double free of mls_level_t) renamed
> > the "defined" field to "notdefined", but did not update this use of
> > it.
> >
> > Use the new field "notdefined" for the check.
>
> Since the renamed member "notdefined" is checked during validation and
> the fuzzer calls policydb_valudate() I think the whole callback can be
> removed.
>

I left it in for now because checkpolicy does a similar check and I
wanted to get this merged as soon as possible since it was breaking
the fuzzer.

> > Signed-off-by: James Carter <jwcart2@gmail.com>

This patch has been merged.

Thanks,
Jim

> > ---
> >  checkpolicy/fuzz/checkpolicy-fuzzer.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/checkpolicy/fuzz/checkpolicy-fuzzer.c b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> > index 0d749a02..a3da0b57 100644
> > --- a/checkpolicy/fuzz/checkpolicy-fuzzer.c
> > +++ b/checkpolicy/fuzz/checkpolicy-fuzzer.c
> > @@ -135,7 +135,7 @@ static int check_level(hashtab_key_t key, hashtab_datum_t datum, void *arg __att
> >         const level_datum_t *levdatum = (level_datum_t *) datum;
> >
> >         // TODO: drop member defined if proven to be always set
> > -       if (!levdatum->isalias && !levdatum->defined) {
> > +       if (!levdatum->isalias && levdatum->notdefined) {
> >                 fprintf(stderr,
> >                         "Error:  sensitivity %s was not used in a level definition!\n",
> >                         key);
> > --
> > 2.44.0
> >
diff mbox series

Patch

diff --git a/checkpolicy/fuzz/checkpolicy-fuzzer.c b/checkpolicy/fuzz/checkpolicy-fuzzer.c
index 0d749a02..a3da0b57 100644
--- a/checkpolicy/fuzz/checkpolicy-fuzzer.c
+++ b/checkpolicy/fuzz/checkpolicy-fuzzer.c
@@ -135,7 +135,7 @@  static int check_level(hashtab_key_t key, hashtab_datum_t datum, void *arg __att
 	const level_datum_t *levdatum = (level_datum_t *) datum;
 
 	// TODO: drop member defined if proven to be always set
-	if (!levdatum->isalias && !levdatum->defined) {
+	if (!levdatum->isalias && levdatum->notdefined) {
 		fprintf(stderr,
 			"Error:  sensitivity %s was not used in a level definition!\n",
 			key);