Re: [PATCH] Fix double-free in secilcheck

Stephen Smalley <[email protected]>
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ4kQ3ZLatTo8tSBCEREj5cJU-jJjKdERGBx3yw8B1ay5Q@mail.gmail.com>
On Tue, Jul 7, 2026 at 10:15 AM James Carter <[email protected]> wrote:
>
> On Tue, Jul 7, 2026 at 8:21 AM Cathy Hu <[email protected]> wrote:
> >
> > If the file size of the cil file is zero, fclose was called twice.
> >
> > Fixes:
> > ```
> > localhost:~ # touch ~/.empty.cil
> > localhost:~ # secilcheck  /etc/selinux/targeted/policy/policy.35 ./empty.cil
> > free(): double free detected in tcache 2
> > Aborted                    (core dumped) secilcheck /etc/selinux/targeted/policy/policy.35 ./empty.cil
> > ```
> >
> > Signed-off-by: Cathy Hu <[email protected]>
>
> Acked-by: James Carter <[email protected]>

Thanks, merged.

>
> > ---
> >  secilc/secilcheck.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/secilc/secilcheck.c b/secilc/secilcheck.c
> > index ee141bc0..b7c32bc6 100644
> > --- a/secilc/secilcheck.c
> > +++ b/secilc/secilcheck.c
> > @@ -155,7 +155,6 @@ static int add_cil_file(const char *filename, struct cil_db *cdb)
> >         file_size = filedata.st_size;
> >
> >         if (!file_size) {
> > -               fclose(file);
> >                 rc = 0;
> >                 goto exit;
> >         }
> > --
> > 2.54.0
> >
> >
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.