lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEjxPJ45hfBr6S1jT3iSOcSiccfWWFcqJC-q9R5qbRndT_DNCA@mail.gmail.com>
Date:   Wed, 26 Aug 2020 08:49:47 -0400
From:   Stephen Smalley <stephen.smalley.work@...il.com>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     Paul Moore <paul@...l-moore.com>,
        Eric Paris <eparis@...isplace.org>,
        Ondrej Mosnacek <omosnace@...hat.com>,
        Jeff Vander Stoep <jeffv@...gle.com>,
        SElinux list <selinux@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] selinux: fix error handling bugs in security_load_policy()

On Wed, Aug 26, 2020 at 7:32 AM Dan Carpenter <dan.carpenter@...cle.com> wrote:
>
> There are a few bugs in the error handling for security_load_policy().
>
> 1) If the newpolicy->sidtab allocation fails then it leads to a NULL
>    dereference.  Also the error code was not set to -ENOMEM on that
>    path.
> 2) If policydb_read() failed then we call policydb_destroy() twice
>    which meands we call kvfree(p->sym_val_to_name[i]) twice.
> 3) If policydb_load_isids() failed then we call sidtab_destroy() twice
>    and that results in a double free in the sidtab_destroy_tree()
>    function because entry.ptr_inner and entry.ptr_leaf are not set to
>    NULL.
>
> One thing that makes this code nice to deal with is that none of the
> functions return partially allocated data.  In other words, the
> policydb_read() either allocates everything successfully or it frees
> all the data it allocates.  It never returns a mix of allocated and
> not allocated data.
>
> I re-wrote this to only free the successfully allocated data which
> avoids the double frees.  I also re-ordered selinux_policy_free() so
> it's in the reverse order of the allocation function.
>
> Fixes: c7c556f1e81b ("selinux: refactor changing booleans")
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>

I guess this wasn't against current selinux next branch?

patching file security/selinux/ss/services.c
Hunk #1 succeeded at 2145 (offset 18 lines).
Hunk #2 succeeded at 2263 (offset 39 lines).
Hunk #3 succeeded at 2303 with fuzz 1 (offset 47 lines).
Hunk #4 succeeded at 2323 (offset 42 lines).

But otherwise it looked good to me.

Acked-by: Stephen Smalley <stephen.smalley.work@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ