diff mbox series

libsepol/cil: Initialize the multiple_decls field of the cil db

Message ID 20200518181251.31862-1-jwcart2@gmail.com (mailing list archive)
State Superseded
Headers show
Series libsepol/cil: Initialize the multiple_decls field of the cil db | expand

Commit Message

James Carter May 18, 2020, 6:12 p.m. UTC
Initialize the multiple_decls field when intializing the structure
cil_db.

Issue reported by: Topi Miettinen <toiwoton@gmail.com>

Fixes: fafe4c212bf6c32c ("libsepol: cil: Add ability to redeclare
       types[attributes]")

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/cil/src/cil.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stephen Smalley May 18, 2020, 6:33 p.m. UTC | #1
On Mon, May 18, 2020 at 2:14 PM James Carter <jwcart2@gmail.com> wrote:
>
> Initialize the multiple_decls field when intializing the structure
> cil_db.
>
> Issue reported by: Topi Miettinen <toiwoton@gmail.com>
>
> Fixes: fafe4c212bf6c32c ("libsepol: cil: Add ability to redeclare
>        types[attributes]")

I guess this explains the non-deterministic behavior and valgrind
warning about uninitialized data, but what about the segfault?
Don't we still need to fix the case when multiple_decls is set to TRUE?

>
> Signed-off-by: James Carter <jwcart2@gmail.com>
> ---
>  libsepol/cil/src/cil.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
> index 4a77aa9c..a3c6a293 100644
> --- a/libsepol/cil/src/cil.c
> +++ b/libsepol/cil/src/cil.c
> @@ -459,6 +459,7 @@ void cil_db_init(struct cil_db **db)
>         (*db)->preserve_tunables = CIL_FALSE;
>         (*db)->handle_unknown = -1;
>         (*db)->mls = -1;
> +       (*db)->multiple_decls = CIL_FALSE;
>         (*db)->target_platform = SEPOL_TARGET_SELINUX;
>         (*db)->policy_version = POLICYDB_VERSION_MAX;
>  }
> --
> 2.25.4
James Carter May 18, 2020, 7:05 p.m. UTC | #2
On Mon, May 18, 2020 at 2:33 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Mon, May 18, 2020 at 2:14 PM James Carter <jwcart2@gmail.com> wrote:
> >
> > Initialize the multiple_decls field when intializing the structure
> > cil_db.
> >
> > Issue reported by: Topi Miettinen <toiwoton@gmail.com>
> >
> > Fixes: fafe4c212bf6c32c ("libsepol: cil: Add ability to redeclare
> >        types[attributes]")
>
> I guess this explains the non-deterministic behavior and valgrind
> warning about uninitialized data, but what about the segfault?
> Don't we still need to fix the case when multiple_decls is set to TRUE?

Yes. I am working on that. I believe the segfault occurs when you
declare something both a type and a typeattribute.

Jim

>
> >
> > Signed-off-by: James Carter <jwcart2@gmail.com>
> > ---
> >  libsepol/cil/src/cil.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
> > index 4a77aa9c..a3c6a293 100644
> > --- a/libsepol/cil/src/cil.c
> > +++ b/libsepol/cil/src/cil.c
> > @@ -459,6 +459,7 @@ void cil_db_init(struct cil_db **db)
> >         (*db)->preserve_tunables = CIL_FALSE;
> >         (*db)->handle_unknown = -1;
> >         (*db)->mls = -1;
> > +       (*db)->multiple_decls = CIL_FALSE;
> >         (*db)->target_platform = SEPOL_TARGET_SELINUX;
> >         (*db)->policy_version = POLICYDB_VERSION_MAX;
> >  }
> > --
> > 2.25.4
diff mbox series

Patch

diff --git a/libsepol/cil/src/cil.c b/libsepol/cil/src/cil.c
index 4a77aa9c..a3c6a293 100644
--- a/libsepol/cil/src/cil.c
+++ b/libsepol/cil/src/cil.c
@@ -459,6 +459,7 @@  void cil_db_init(struct cil_db **db)
 	(*db)->preserve_tunables = CIL_FALSE;
 	(*db)->handle_unknown = -1;
 	(*db)->mls = -1;
+	(*db)->multiple_decls = CIL_FALSE;
 	(*db)->target_platform = SEPOL_TARGET_SELINUX;
 	(*db)->policy_version = POLICYDB_VERSION_MAX;
 }